19 package org.turro.contacts.profile;
21 import java.util.List;
23 import java.util.function.Predicate;
24 import java.util.stream.Collectors;
25 import org.turro.string.Strings;
26 import org.turro.action.Actions;
27 import org.turro.action.Contacts;
28 import org.turro.assistant.ParticipationInfo;
29 import org.turro.auth.Authentication;
30 import org.turro.contacts.BusinessRelation;
31 import org.turro.contacts.Contact;
32 import org.turro.contacts.ContactService;
33 import org.turro.contacts.JobBoard;
34 import org.turro.contacts.db.ContactsPU;
35 import org.turro.contacts.relation.Business;
36 import org.turro.contacts.relation.Relations;
37 import org.turro.elephant.context.Application;
38 import org.turro.elephant.context.IConstructor;
39 import org.turro.elephant.entities.db.Skill;
40 import org.turro.elephant.entities.db.SkillType;
41 import org.turro.elephant.impl.repository.RepositoryFile;
42 import org.turro.elephant.impl.util.Files;
43 import org.turro.elephant.security.IUser;
44 import org.turro.elephant.util.Images;
45 import org.turro.entities.Controls;
46 import org.turro.entities.Entities;
47 import org.turro.entities.IElephantEntity;
48 import org.turro.file.util.FileAttach;
49 import org.turro.participation.ParticipationReason;
50 import org.turro.plugin.contacts.IContact;
51 import org.turro.plugin.contacts.IContactRelation;
52 import org.turro.plugin.contacts.IProfile;
53 import org.turro.skills.Skills;
61 public final static String
PHONE =
"PhoneProfile",
63 NETWORK =
"NetworkProfile";
67 private final List<ProfileRelation> companies, learningCenters;
70 private final List<Skill> knowledge, functional, attitude, sector, specialty;
72 private boolean edit =
false;
86 this.policy = policy ==
null ? takeRequiredFromLogged() : policy;
88 this.companies = loadCompanies();
89 this.learningCenters = loadLearningCenters();
90 this.knowledge = loadKnowledge();
91 this.functional = loadFunctional();
92 this.attitude = loadAttitude();
93 this.sector = loadSector();
94 this.specialty = loadSpecialty();
184 return !Strings.isBlank(
getAbout());
195 if(publicDocs ==
null) {
200 return publicDocs !=
null && publicDocs.
hasContent();
216 return getCompanies().stream().filter(r -> r.isInRange()).collect(Collectors.toList());
220 return getCompanies().stream().filter(r -> !r.isInRange()).collect(Collectors.toList());
224 return isEdit() ? companies : companies.stream().filter(r -> r.isValidated()).collect(Collectors.toList());
228 return getLearningCenters().stream().filter(r -> r.isInRange()).collect(Collectors.toList());
232 return getLearningCenters().stream().filter(r -> !r.isInRange()).collect(Collectors.toList());
236 return isEdit() ? learningCenters : learningCenters.stream().filter(r -> r.isValidated()).collect(Collectors.toList());
241 (!knowledge.isEmpty() || !functional.isEmpty() || !attitude.isEmpty()) &&
258 return isJuridical() && (!sector.isEmpty() || !specialty.isEmpty());
280 return policies.
getPolicy(entity, element);
313 return contact.
isUser() ?
"/user/profile" :
339 return getCurrentCenters().stream().anyMatch(r -> r.getRelation().isResponsible());
389 public boolean isLogged(Predicate<BusinessRelation> predicate) {
404 private boolean hasCurrentRelations() {
408 private List<ProfileRelation> loadCompanies() {
409 return business.stream().filter(r -> r.isWorker())
410 .map(r ->
new ProfileRelation(r, policies, policy)).collect(Collectors.toList());
413 private List<ProfileRelation> loadLearningCenters() {
414 return business.stream().filter(r -> r.isStudent())
415 .map(r ->
new ProfileRelation(r, policies, policy)).collect(Collectors.toList());
418 private List<Skill> loadKnowledge() {
419 return Skills.getSkillsFrom(
getEntityPath(), SkillType.SKILL_KNOWLEDGE);
422 private List<Skill> loadAttitude() {
423 return Skills.getSkillsFrom(
getEntityPath(), SkillType.SKILL_ATTITUDE);
426 private List<Skill> loadFunctional() {
427 return Skills.getSkillsFrom(
getEntityPath(), SkillType.SKILL_FUNCTIONAL);
430 private List<Skill> loadSector() {
431 return Skills.getSkillsFrom(
getEntityPath(), SkillType.SKILL_SECTOR);
434 private List<Skill> loadSpecialty() {
435 return Skills.getSkillsFrom(
getEntityPath(), SkillType.SKILL_SPECIALTY);
438 private PublishPolicy takeRequiredFromLogged() {
439 IContact logged = Authentication.getIContact();
440 if(logged ==
null || !logged.isValid()) {
441 return PublishPolicy.PUBLISH_ALL;
442 }
else if(logged.equals(contact)) {
443 return PublishPolicy.PUBLISH_NONE;
444 }
else if(
new ParticipationInfo(contact, logged, ParticipationReason.REASON_FOLLOW).isChecked()) {
445 return PublishPolicy.PUBLISH_FOLLOWING;
447 return PublishPolicy.PUBLISH_USERS;
451 private boolean isBusiness() {
455 private boolean isLoggedAdmin() {
456 IContact logged = Authentication.getIContact();
457 return logged !=
null && logged.isValid() && logged.isAdmin();
static String createRightNowAction(String values)
static IContact getIContact()
static boolean hasContact()
static boolean isLogged(IContact contact)
static String getNetworkingRoles()
static boolean getShowCompletion()
static boolean hasCompanies()
static boolean hasCenters()
static boolean getWebOnUsers()
static String getPremiumNetworkingRoles()
IConstructor getConstructor()
static Application getApplication()
static boolean exists(String path)
static String getImageOrNull(String image)
static String getImageOrDefault(String image)
static IElephantEntity getController(String path)
Repository getPublishableRepository(IConstructor constructor)
boolean isInRole(String role)
static final String CONNECTOR_TRADE
String parseFollowCtrl(IConstructor constructor)
Object getControl(String name, IConstructor constructor, IContact contact)