19 package org.turro.alliance.content.control;
21 import java.util.Date;
22 import org.turro.alliance.db.AlliancePU;
23 import org.turro.alliance.db.entities.RelationId;
24 import org.turro.jpa.Dao;
25 import org.turro.server.db.entities.AxAllianceParticipation;
26 import org.turro.server.db.entities.AxParticipationRequest;
27 import org.turro.util.Cached;
36 dao.get().saveObject(addUp(
get()));
39 public void delete() {
40 dao.get().deleteObject(request);
44 dao.get().saveObject(addUpRequest(getRequest()));
54 private AxAllianceParticipation addUp(AxAllianceParticipation participation) {
55 if(participation ==
null) {
56 participation =
new AxAllianceParticipation();
58 participation.setCreation(
new Date());
60 participation.setCompany(request.
getCompany());
62 participation.setFace(request.
getFace());
64 participation.setName(request.
getName());
65 if(request.
isAdmin()) participation.setAdmin(
true);
66 if(request.
isBeneficiary()) participation.setBeneficiary(
true);
67 if(request.
isConsortium()) participation.setConsortium(
true);
68 if(request.
isCoordinator()) participation.setCoordinator(
true);
69 if(request.
isDriver()) participation.setDriver(
true);
70 if(request.
isFunding()) participation.setFunding(
true);
71 if(request.
isOfferer()) participation.setOfferer(
true);
72 if(request.
isResearch()) participation.setResearch(
true);
73 if(request.
isSupport()) participation.setSupport(
true);
77 private AxParticipationRequest getRequest() {
79 return dao.get().find(AxParticipationRequest.class, rid);
82 private AxParticipationRequest addUpRequest(AxParticipationRequest participation) {
83 if(participation ==
null) {
84 participation =
new AxParticipationRequest();
86 participation.setCreation(
new Date());
88 participation.setCompany(request.
getCompany());
90 participation.setFace(request.
getFace());
92 participation.setName(request.
getName());
93 if(request.
isAdmin()) participation.setAdmin(
true);
94 if(request.
isBeneficiary()) participation.setBeneficiary(
true);
95 if(request.
isConsortium()) participation.setConsortium(
true);
96 if(request.
isCoordinator()) participation.setCoordinator(
true);
97 if(request.
isDriver()) participation.setDriver(
true);
98 if(request.
isFunding()) participation.setFunding(
true);
99 if(request.
isOfferer()) participation.setOfferer(
true);
100 if(request.
isResearch()) participation.setResearch(
true);
101 if(request.
isSupport()) participation.setSupport(
true);
102 return participation;
107 private final Cached<Dao> dao = Cached.instance(() ->
new AlliancePU());
118 this.request = request;
static Participations from(AxParticipationRequest request)