19 package org.turro.importer;
21 import java.util.HashSet;
22 import java.util.List;
24 import org.turro.alliance.db.AlliancePU;
25 import org.turro.alliance.db.entities.AxCenter;
26 import org.turro.alliance.db.entities.AxChallenge;
27 import org.turro.alliance.db.entities.AxContact;
28 import org.turro.alliance.db.entities.AxDescriptor;
29 import org.turro.alliance.db.entities.AxParticipation;
30 import org.turro.alliance.db.entities.AxProject;
31 import org.turro.alliance.db.entities.AxProjectGrant;
32 import org.turro.alliance.db.entities.AxResponse;
33 import org.turro.alliance.db.entities.AxStudent;
34 import org.turro.alliance.db.entities.AxTag;
35 import org.turro.alliance.service.AxConstants;
36 import org.turro.alliance.service.AxClient;
37 import org.turro.jpa.Dao;
38 import org.turro.json.Jsons;
39 import org.turro.log.WebLoggers;
40 import org.turro.sql.SqlClause;
41 import org.turro.tags.Tags;
42 import org.turro.ws.WsMember;
43 import org.turro.ws.service.server.Clients;
53 if(Clients.checkClientService(member.getMemberDomain(), member.getService())) {
78 }
catch(Exception ex) {
84 json.getStructure().asArray().forEach(contact -> {
90 json.getStructure().asArray().forEach(project -> {
92 Set<AxDescriptor> descriptors =
new HashSet<>();
95 getDao().saveEntity(tmp);
103 json.getStructure().asArray().forEach(projectGrant -> {
105 getDao().saveEntity(tmp);
110 json.getStructure().asArray().forEach(center -> {
112 getDao().saveEntity(tmp);
117 json.getStructure().asArray().forEach(student -> {
119 getDao().saveEntity(tmp);
124 json.getStructure().asArray().forEach(challenge -> {
126 Set<AxResponse> responses =
new HashSet<>();
129 getDao().saveEntity(tmp);
137 json.getStructure().asArray().forEach(tag -> {
144 for(ImporterRegister
register : data) {
150 for(ImporterRegister
register : data) {
156 for(ImporterRegister
register : data) {
162 for(ImporterRegister
register : data) {
169 SqlClause.delete(
"AxContact")
170 .where().equal(
"contactId.memberId", member.
getMemberId())
176 SqlClause.delete(
"AxProject")
177 .where().equal(
"projectId.memberId", member.
getMemberId())
183 SqlClause.delete(
"AxParticipation")
184 .where().equal(
"relation.mainMemberId", member.
getMemberId())
185 .or().equal(
"relation.relatedMemberId", member.
getMemberId())
191 SqlClause.delete(
"AxDescriptor")
198 SqlClause.delete(
"AxProjectGrant")
199 .where().equal(
"projectGrantId.memberId", member.
getMemberId())
205 SqlClause.delete(
"AxCenter")
206 .where().equal(
"centerId.memberId", member.
getMemberId())
212 SqlClause.delete(
"AxStudent")
213 .where().equal(
"studentId.memberId", member.
getMemberId())
219 SqlClause.delete(
"AxChallenge")
220 .where().equal(
"challengeId.memberId", member.
getMemberId())
223 SqlClause.delete(
"AxResponse")
224 .where().equal(
"relation.mainMemberId", member.
getMemberId())
225 .or().equal(
"relation.relatedMemberId", member.
getMemberId())
238 private Dao getDao() {
static AxCenter fromJson(JsonValue value)
Set< AxResponse > getResponses()
static AxChallenge fromJson(JsonValue value)
void setResponses(Set< AxResponse > responses)
static Set< AxParticipation > from(long memberId, Dossier dossier)
static AxProjectGrant fromJson(JsonValue value)
static AxProject from(long memberId, WsServer server, Dossier dossier, AxProjectCategory pc)
void setDescriptors(Set< AxDescriptor > descriptors)
Set< AxDescriptor > getDescriptors()
static AxProject fromJson(JsonValue value)
static AxStudent fromJson(JsonValue value)
static AxTag fromJson(JsonValue value)
static Set< AxTag > from(long memberId, Dossier dossier)
static final String CLIENT_SERVICE
void importStudentsFromJson(WsMember member, Jsons json)
void removeParticipationsFromMember(WsMember member)
void removeProjectsFromMember(WsMember member)
void removeChallengesFromMember(WsMember member)
void importTagsFromRegister(WsMember member, List< ImporterRegister > data)
void importProjectGrantsFromJson(WsMember member, Jsons json)
void importProjectsFromJson(WsMember member, Jsons json)
void removeCentersFromMember(WsMember member)
void removeContactsFromMember(WsMember member)
void importContactsFromRegister(WsMember member, List< ImporterRegister > data)
void removeProjectGrantsFromMember(WsMember member)
void importProjectsFromRegister(WsMember member, List< ImporterRegister > data)
static void connect(WsMember member)
void removeStudentsFromMember(WsMember member)
void importTagsFromJson(WsMember member, Jsons json)
void removeDescriptorsFromMember(WsMember member)
void importChallengesFromJson(WsMember member, Jsons json)
void importParticipationsFromRegister(WsMember member, List< ImporterRegister > data)
void removeTagsFromMember(WsMember member)
void importContactsFromJson(WsMember member, Jsons json)
void importCentersFromJson(WsMember member, Jsons json)
void persistObject(Object obj)
WebLoggers message(String text, Object... parameters)
static WebLoggers severe(Object entity)
WebLoggers exception(Throwable throwable)