19 package org.turro.alliance.db.entities;
21 import java.io.Serializable;
22 import java.util.Date;
23 import java.util.List;
25 import java.util.Objects;
27 import java.util.TreeSet;
28 import javax.json.JsonValue;
29 import javax.persistence.CascadeType;
30 import javax.persistence.EmbeddedId;
31 import javax.persistence.Entity;
32 import javax.persistence.FetchType;
33 import javax.persistence.JoinColumn;
34 import javax.persistence.JoinColumns;
35 import javax.persistence.OneToMany;
36 import javax.persistence.Temporal;
37 import org.turro.string.Phrases;
38 import org.turro.string.Strings;
39 import org.hibernate.annotations.Formula;
40 import org.turro.alliance.content.AlliancePhaseDefinitions;
41 import org.turro.alliance.db.AlliancePU;
42 import org.turro.dossier.entity.Dossier;
43 import org.turro.elephant.context.ElephantContext;
44 import org.turro.entities.Entities;
45 import org.turro.importer.ImporterRegister;
46 import org.turro.jpa.entity.IDaoEntity;
47 import org.turro.json.IJSONizable;
48 import org.turro.member.db.entities.AxProjectCategory;
49 import org.turro.phase.PhaseDefinition;
50 import org.turro.phase.PhaseDefinitions;
51 import org.turro.server.db.entities.AxAllianceParticipation;
52 import org.turro.sql.SqlClause;
53 import org.turro.ws.WsServer;
64 private Long categoryId;
66 @Formula(
"concat(entityId,'##',memberId)")
69 @Temporal(value = javax.persistence.TemporalType.TIMESTAMP)
70 private java.util.Date creation;
72 private int phaseIndex;
74 private String code, name, summary, searching;
76 private String sourceLink;
78 @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.MERGE)
80 @JoinColumn(name=
"mainEntityId", referencedColumnName =
"entityId", insertable =
false, updatable =
false),
81 @JoinColumn(name=
"mainMemberId", referencedColumnName =
"memberId", insertable =
false, updatable =
false)
83 private Set<AxParticipation> participations;
85 @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.MERGE)
87 @JoinColumn(name=
"entityId", referencedColumnName =
"entityId", insertable =
false, updatable =
false),
88 @JoinColumn(name=
"memberId", referencedColumnName =
"memberId", insertable =
false, updatable =
false)
90 private Set<AxDescriptor> descriptors;
97 this.projectId = projectId;
105 this.categoryId = categoryId;
117 this.creation = creation;
125 this.phaseIndex = phaseIndex;
149 this.summary = summary;
157 this.searching = searching;
161 return participations;
165 this.participations = participations;
173 this.descriptors = descriptors;
189 this.sourceLink = sourceLink;
193 return Phrases.start(code, name).toString();
199 return new TreeSet<>(descriptors);
206 .map(p -> p.getContact()).toList();
211 .map(p -> p.getContact()).toList();
216 .map(p -> p.getContact()).toList();
221 .map(p -> p.getContact()).toList();
226 .map(p -> p.getContact()).toList();
231 .map(p -> p.getContact()).toList();
236 .map(p -> p.getContact()).toList();
241 .map(p -> p.getContact()).toList();
278 private transient List<AxAllianceParticipation> allianceParticipations;
281 if(allianceParticipations ==
null) {
282 allianceParticipations = SqlClause.select(
"p").from(
"AxAllianceParticipation p")
283 .where().equal(
"mainEntityId", projectId.getEntityId())
284 .and().equal(
"mainMemberId", projectId.getMemberId())
288 return allianceParticipations;
314 id.setMemberId(memberId);
315 id.setEntityId(Long.toString(dossier.
getId()));
333 id.setMemberId(memberId);
334 id.setEntityId(
register.getString(
"projectId"));
338 axp.
setCode(
register.getString(
"projectCode"));
339 axp.
setName(
register.getString(
"name"));
340 axp.
setSummary(
register.getString(
"summary"));
355 return projectId.isEmpty() ||
356 Strings.isBlank(name);
367 public String
toJson(Map<String, Object> properties) {
368 return toJson(
this, properties);
380 hash = 79 * hash + Objects.hashCode(this.projectId);
392 if (getClass() != obj.getClass()) {
396 return Objects.
equals(this.projectId, other.projectId);
static AlliancePhaseDefinitions instance()
PhaseDefinition get(int index)
static Set< AxDescriptor > from(AxProject project, Dossier dossier)
static Set< AxParticipation > from(long memberId, Dossier dossier)
List< AxParticipation > getCoordinatorParticipations()
static AxProject from(long memberId, ImporterRegister register)
void setCode(String code)
List< AxParticipation > getSupportParticipations()
String toJson(Map< String, Object > properties)
List< AxParticipation > getConsortiumParticipations()
boolean equals(Object obj)
ProcedenceId getProjectId()
List< AxContact > getResearch()
static AxProject from(long memberId, WsServer server, Dossier dossier, AxProjectCategory pc)
List< AxContact > getConsortium()
List< AxContact > getBeneficiaries()
void setDescriptors(Set< AxDescriptor > descriptors)
List< AxContact > getSupport()
Set< AxParticipation > getParticipations()
void setSearching(String searching)
void setProjectId(ProcedenceId projectId)
List< AxContact > getCoordinators()
Set< AxDescriptor > getSortedDescriptors()
List< AxParticipation > getFundingParticipations()
List< AxParticipation > getResearchParticipations()
List< AxContact > getOfferers()
Set< AxDescriptor > getDescriptors()
void setSourceLink(String sourceLink)
void setPhaseIndex(int phaseIndex)
List< AxParticipation > getOffererParticipations()
void setName(String name)
void setCategoryId(Long categoryId)
void setCreation(Date creation)
List< AxAllianceParticipation > getAllianceParticipations()
List< AxContact > getDrivers()
void setSummary(String summary)
void setCategory(AxCategory category)
List< AxAllianceParticipation > getConsortiumAxParticipations()
List< AxAllianceParticipation > getBeneficiaryAxParticipations()
static AxProject fromJson(JsonValue value)
List< AxParticipation > getDriverParticipations()
void setParticipations(Set< AxParticipation > participations)
PhaseDefinition getPhase()
List< AxContact > getFunding()
List< AxParticipation > getBeneficiaryParticipations()
List< AxAllianceParticipation > getOffererAxParticipations()
static String getServerUrl(String scheme)
static IElephantEntity getController(String path)
int getMapping(int index, String serverId)
static PhaseDefinitions instance()