annotate src/main/java/de/mpiwg/itgroup/ismi/entry/utils/PrivacityUtils.java @ 216:93d33f138c9e default tip

update medeniyet image server URL.
author casties
date Wed, 26 Jan 2022 16:39:32 +0100
parents c7fec83ab69a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
jurzua
parents:
diff changeset
1 package de.mpiwg.itgroup.ismi.entry.utils;
jurzua
parents:
diff changeset
2
jurzua
parents:
diff changeset
3 import java.util.ArrayList;
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
4 import java.util.Arrays;
189
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
5 import java.util.HashMap;
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
6 import java.util.HashSet;
1
jurzua
parents:
diff changeset
7 import java.util.List;
189
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
8 import java.util.Map;
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
9 import java.util.Set;
1
jurzua
parents:
diff changeset
10
jurzua
parents:
diff changeset
11 import org.mpi.openmind.cache.WrapperService;
jurzua
parents:
diff changeset
12 import org.mpi.openmind.repository.bo.Entity;
jurzua
parents:
diff changeset
13 import org.mpi.openmind.repository.bo.Relation;
jurzua
parents:
diff changeset
14
jurzua
parents:
diff changeset
15 public class PrivacityUtils {
jurzua
parents:
diff changeset
16
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
17 public static final Set<String> TEXTexcepts = new HashSet<String>(Arrays.asList("TEXT"));
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
18 public static final Set<String> PERSONexcepts = new HashSet<String>(Arrays.asList("TEXT", "PERSON", "WITNESS",
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
19 "CODEX", "TRANSFER_EVENT", "STUDY_EVENT", "COPY_EVENT", "MISATTRIBUTION", "MISIDENTIFICATION"));
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
20 public static final Set<String> WITNESSexcepts = new HashSet<String>(Arrays.asList("WITNESS", "TEXT"));
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
21 public static final Set<String> CODEXexcepts = new HashSet<String>(Arrays.asList("WITNESS"));
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
22 public static final Set<String> COLLECTIONexcepts = new HashSet<String>(Arrays.asList("CODEX"));
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
23 public static final Set<String> REPOSITORYexcepts = new HashSet<String>(Arrays.asList("COLLECTION", "STUDY_EVENT", "COPY_EVENT"));
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
24
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
25
148
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
26 /**
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
27 * Change public state of the given entity.
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
28 *
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
29 * Toggles public state if isPublic == null.
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
30 *
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
31 * Returns the changed Entity (that needs to be saved).
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
32 *
148
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
33 * @param entity
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
34 * @param isPublic
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
35 * @param wrapper
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
36 * @return
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
37 */
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
38 public static Entity changeEntityPrivacity(Entity entity, Boolean isPublic, WrapperService wrapper) {
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
39 // make sure attributes are loaded
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
40 if (entity.isLightweight()) {
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
41 entity = wrapper.getEntityContent(entity);
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
42 }
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
43 // toggle public if isPublic == null
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
44 if (isPublic == null) {
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
45 isPublic = !entity.getIsPublic();
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
46 }
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
47 // set public
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
48 entity.setIsPublic(isPublic);
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
49 return entity;
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
50 }
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
51
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
52 /**
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
53 * Change public state of all entities directly related to the given entity
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
54 * (does not change the given entity).
148
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
55 *
150
29c4b64caad0 small cleanup; add mams_number field for PERSON.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 148
diff changeset
56 * Sets public state to given entity's state if isPublic == null.
148
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
57 *
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
58 * Does not touch Entities of the types listed in exceptedTypes.
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
59 *
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
60 * Returns a List of Entities that have been changed (and need to be saved).
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
61 *
148
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
62 * @param entity
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
63 * @param isPublic
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
64 * @param wrapper
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
65 * @param exceptedTypes
189
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
66 * @param alreadyModified TODO
148
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
67 * @return
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
68 */
189
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
69 public static Map<Long, Entity> setRelatedEntitiesPrivacity(Entity entity, Boolean isPublic, WrapperService wrapper,
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
70 Set<String> exceptedTypes, Map<Long, Entity> alreadyModified) {
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
71 Map<Long,Entity> modified = new HashMap<Long,Entity>();
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
72 // make sure relations are loaded
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
73 if (entity.isLightweight()) {
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
74 entity = wrapper.getEntityContent(entity);
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
75 }
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
76
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
77 // use entity's public if isPublic == null
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
78 if (isPublic == null) {
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
79 isPublic = entity.getIsPublic();
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
80 }
148
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
81
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
82 // change source relations
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
83 for (Relation rel : entity.getSourceRelations()) {
194
c7fec83ab69a fix bugs with make-public buttons in entity details form. Closes #152.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 189
diff changeset
84 if (exceptedTypes != null && exceptedTypes.contains(rel.getTargetObjectClass())) {
c7fec83ab69a fix bugs with make-public buttons in entity details form. Closes #152.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 189
diff changeset
85 continue;
c7fec83ab69a fix bugs with make-public buttons in entity details form. Closes #152.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 189
diff changeset
86 } else {
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
87 Long entId = rel.getTargetId();
189
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
88 if (alreadyModified.containsKey(entId)) {
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
89 continue;
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
90 }
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
91 Entity ent = wrapper.getEntityById(entId);
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
92 ent.setIsPublic(isPublic);
189
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
93 modified.put(entId, ent);
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
94 }
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
95 }
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
96 // change target relations
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
97 for (Relation rel : entity.getTargetRelations()) {
194
c7fec83ab69a fix bugs with make-public buttons in entity details form. Closes #152.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 189
diff changeset
98 if (exceptedTypes != null && exceptedTypes.contains(rel.getSourceObjectClass())) {
c7fec83ab69a fix bugs with make-public buttons in entity details form. Closes #152.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 189
diff changeset
99 continue;
c7fec83ab69a fix bugs with make-public buttons in entity details form. Closes #152.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 189
diff changeset
100 } else {
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
101 Long entId = rel.getSourceId();
189
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
102 if (alreadyModified.containsKey(entId)) {
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
103 continue;
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
104 }
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
105 Entity ent = wrapper.getEntityById(entId);
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
106 ent.setIsPublic(isPublic);
189
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
107 modified.put(entId, ent);
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
108 }
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
109 }
189
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
110 return modified;
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
111 }
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
112
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
113 /**
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
114 * Change public state of a TEXT and all meaningfully related Entities.
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
115 *
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
116 * Sets public state to given entity's state if isPublic == null.
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
117 *
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
118 * Returns a List of Entities that have been changed (and need to be saved).
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
119 *
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
120 * @param text
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
121 * @param isPublic
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
122 * @param wrapper
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
123 * @return
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
124 * @throws Exception
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
125 */
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
126 public static List<Entity> setTextAndMorePrivacity(Entity text, Boolean isPublic, List<String> report,
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
127 WrapperService wrapper) throws Exception {
189
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
128 Map<Long,Entity> modified = new HashMap<Long,Entity>();
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
129 // make sure relations are loaded
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
130 if (text.isLightweight()) {
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
131 text = wrapper.getEntityContent(text);
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
132 }
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
133
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
134 // use entity's public if isPublic == null
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
135 if (isPublic == null) {
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
136 isPublic = text.getIsPublic();
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
137 }
148
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
138
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
139 /*
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
140 * mark text public
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
141 */
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
142 text.setIsPublic(isPublic);
189
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
143 modified.put(text.getId(), text);
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
144 report.add("Set public="+isPublic+" on "+text.getShortString()+"\n");
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
145
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
146 /*
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
147 * mark directly related objects except TEXT
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
148 */
189
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
149 Map<Long, Entity> relatedEnts = setRelatedEntitiesPrivacity(text, isPublic, wrapper, TEXTexcepts, modified);
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
150 modified.putAll(relatedEnts);
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
151 report.add("Set public="+isPublic+" on related entities to "+text.getShortString()+" : ["+Entity.getShortStringList(relatedEnts.values())+"]\n");
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
152
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
153 /*
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
154 * follow relations of related objects
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
155 */
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
156 int cnt = 0;
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
157 do {
189
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
158 Map<Long, Entity> nextRelEnts = new HashMap<Long,Entity>();
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
159 for (Entity relEnt : relatedEnts.values()) {
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
160 String entType = relEnt.getObjectClass();
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
161 if (entType.equals("PERSON")) {
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
162 // PERSON
189
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
163 Map<Long, Entity> persRelEnts = setRelatedEntitiesPrivacity(relEnt, isPublic, wrapper, PERSONexcepts, modified);
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
164 modified.putAll(persRelEnts);
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
165 nextRelEnts.putAll(persRelEnts);
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
166 report.add("Set public="+isPublic+" on related entities to "+relEnt.getShortString()+" : ["+Entity.getShortStringList(persRelEnts.values())+"]\n");
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
167 } else if (entType.equals("WITNESS")) {
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
168 // WITNESS
189
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
169 Map<Long, Entity> witRelEnts = setRelatedEntitiesPrivacity(relEnt, isPublic, wrapper, WITNESSexcepts, modified);
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
170 modified.putAll(witRelEnts);
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
171 nextRelEnts.putAll(witRelEnts);
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
172 report.add("Set public="+isPublic+" on related entities to "+relEnt.getShortString()+" : ["+Entity.getShortStringList(witRelEnts.values())+"]\n");
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
173 } else if (entType.equals("CODEX")) {
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
174 // CODEX
189
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
175 Map<Long, Entity> codRelEnts = setRelatedEntitiesPrivacity(relEnt, isPublic, wrapper, CODEXexcepts, modified);
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
176 modified.putAll(codRelEnts);
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
177 nextRelEnts.putAll(codRelEnts);
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
178 report.add("Set public="+isPublic+" on related entities to "+relEnt.getShortString()+" : ["+Entity.getShortStringList(codRelEnts.values())+"]\n");
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
179 } else if (entType.equals("COLLECTION")) {
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
180 // COLLECTION
189
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
181 Map<Long, Entity> colRelEnts = setRelatedEntitiesPrivacity(relEnt, isPublic, wrapper, COLLECTIONexcepts, modified);
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
182 modified.putAll(colRelEnts);
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
183 nextRelEnts.putAll(colRelEnts);
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
184 report.add("Set public="+isPublic+" on related entities to "+relEnt.getShortString()+" : ["+Entity.getShortStringList(colRelEnts.values())+"]\n");
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
185 } else if (entType.equals("REPOSITORY")) {
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
186 // REPOSITORY
189
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
187 Map<Long, Entity> repRelEnts = setRelatedEntitiesPrivacity(relEnt, isPublic, wrapper, REPOSITORYexcepts, modified);
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
188 modified.putAll(repRelEnts);
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
189 nextRelEnts.putAll(repRelEnts);
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
190 report.add("Set public="+isPublic+" on related entities to "+relEnt.getShortString()+" : ["+Entity.getShortStringList(repRelEnts.values())+"]\n");
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
191 } else if (entType.endsWith("_EVENT")) {
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
192 // *_EVENT: mark all related entities
189
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
193 Map<Long, Entity> evRelEnts = setRelatedEntitiesPrivacity(relEnt, isPublic, wrapper, null, modified);
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
194 modified.putAll(evRelEnts);
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
195 nextRelEnts.putAll(evRelEnts);
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
196 report.add("Set public="+isPublic+" on related entities to "+relEnt.getShortString()+" : ["+Entity.getShortStringList(evRelEnts.values())+"]\n");
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
197 } else {
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
198 // everything else?
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
199 }
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
200 }
189
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
201 if (nextRelEnts.equals(relatedEnts)) {
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
202 report.add("WARNING: had to break from loop!\n");
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
203 break;
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
204 }
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
205 // start with next level
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
206 relatedEnts = nextRelEnts;
189
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
207 } while (!relatedEnts.isEmpty() && ++cnt < 10);
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
208 if (cnt == 10) {
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
209 report.add("ERROR: relation depth limit exceeded!");
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
210 throw new Exception("Relation depth limit exceeded when marking text public!");
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
211 }
189
8aff920ec7c0 fix problem with making entities public when there are loops in the relations.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 175
diff changeset
212 return new ArrayList<Entity>(modified.values());
148
b40a84944716 add public/private editing to Entity Details.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 1
diff changeset
213 }
1
jurzua
parents:
diff changeset
214
175
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
215
3d8b31508128 PublicByAuthor feature works now.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents: 150
diff changeset
216
1
jurzua
parents:
diff changeset
217 public static List<Entity> changePrivacity4Person(Entity person, Boolean isPublic, WrapperService wrapper){
jurzua
parents:
diff changeset
218 List<Entity> saveList = new ArrayList<Entity>();
jurzua
parents:
diff changeset
219
jurzua
parents:
diff changeset
220 if(person.isLightweight()){
jurzua
parents:
diff changeset
221 person = wrapper.getEntityContent(person);
jurzua
parents:
diff changeset
222 }
jurzua
parents:
diff changeset
223
jurzua
parents:
diff changeset
224 boolean privacity = false;
jurzua
parents:
diff changeset
225 if(isPublic == null){
jurzua
parents:
diff changeset
226 privacity = !person.getIsPublic();
jurzua
parents:
diff changeset
227 }else{
jurzua
parents:
diff changeset
228 privacity = isPublic;
jurzua
parents:
diff changeset
229 }
jurzua
parents:
diff changeset
230
jurzua
parents:
diff changeset
231 person.setIsPublic(privacity);
jurzua
parents:
diff changeset
232 saveList.add(person);
jurzua
parents:
diff changeset
233
jurzua
parents:
diff changeset
234 List<Relation> relList = null;
jurzua
parents:
diff changeset
235 //loading relations
jurzua
parents:
diff changeset
236 if(privacity){
jurzua
parents:
diff changeset
237 relList = new ArrayList<Relation>(person.getSourceRelations());
jurzua
parents:
diff changeset
238 for (Relation rel : relList) {
jurzua
parents:
diff changeset
239 String relName = rel.getOwnValue();
jurzua
parents:
diff changeset
240 if (relName.equals("was_born_in") ||
jurzua
parents:
diff changeset
241 relName.equals("lived_in") ||
jurzua
parents:
diff changeset
242 relName.equals("was_student_of") ||
jurzua
parents:
diff changeset
243 relName.equals("has_role") ||
jurzua
parents:
diff changeset
244 relName.equals("died_in")) {
jurzua
parents:
diff changeset
245 Entity target = wrapper.getEntityById(rel.getTargetId());
jurzua
parents:
diff changeset
246 //target = wrapper.getEntityContent(target);
jurzua
parents:
diff changeset
247 target.setIsPublic(privacity);
jurzua
parents:
diff changeset
248 saveList.add(target);
jurzua
parents:
diff changeset
249 }
jurzua
parents:
diff changeset
250 }
jurzua
parents:
diff changeset
251 }
jurzua
parents:
diff changeset
252
jurzua
parents:
diff changeset
253 relList = new ArrayList<Relation>(person.getTargetRelations());
jurzua
parents:
diff changeset
254 for (Relation rel : relList) {
jurzua
parents:
diff changeset
255 String relName = rel.getOwnValue();
jurzua
parents:
diff changeset
256 //title were be not included into this list
jurzua
parents:
diff changeset
257 if (relName.equals("is_alias_name_of") || relName.equals("is_prime_alias_name_of")) {
jurzua
parents:
diff changeset
258 Entity source = wrapper.getEntityById(rel.getSourceId());
jurzua
parents:
diff changeset
259 //source = wrapper.getEntityContent(source);
jurzua
parents:
diff changeset
260 source.setIsPublic(privacity);
jurzua
parents:
diff changeset
261 saveList.add(source);
jurzua
parents:
diff changeset
262 }
jurzua
parents:
diff changeset
263 }
jurzua
parents:
diff changeset
264
jurzua
parents:
diff changeset
265 return saveList;
jurzua
parents:
diff changeset
266 }
jurzua
parents:
diff changeset
267
jurzua
parents:
diff changeset
268 public static List<Entity> changePrivacity4Title(Entity title, Boolean isPublic, WrapperService wrapper){
jurzua
parents:
diff changeset
269 List<Entity> saveList = new ArrayList<Entity>();
jurzua
parents:
diff changeset
270
jurzua
parents:
diff changeset
271 /*
jurzua
parents:
diff changeset
272 if(title.isLightweight()){
jurzua
parents:
diff changeset
273 title = wrapper.getEntityContent(title);
jurzua
parents:
diff changeset
274 }*/
jurzua
parents:
diff changeset
275
jurzua
parents:
diff changeset
276 boolean privacity = false;
jurzua
parents:
diff changeset
277 if(isPublic == null){
jurzua
parents:
diff changeset
278 privacity = !title.getIsPublic();
jurzua
parents:
diff changeset
279 }else{
jurzua
parents:
diff changeset
280 privacity = isPublic;
jurzua
parents:
diff changeset
281 }
jurzua
parents:
diff changeset
282
jurzua
parents:
diff changeset
283 title.setIsPublic(privacity);
jurzua
parents:
diff changeset
284 saveList.add(title);
jurzua
parents:
diff changeset
285
jurzua
parents:
diff changeset
286 if(privacity){
jurzua
parents:
diff changeset
287 for(Entity ent : wrapper.getTargetsForSourceRelation(title, "has_subject", "SUBJECT", 1)){
jurzua
parents:
diff changeset
288 //if(ent.isLightweight())
jurzua
parents:
diff changeset
289 // ent = wrapper.getEntityContent(ent);
jurzua
parents:
diff changeset
290 ent.setIsPublic(privacity);
jurzua
parents:
diff changeset
291 saveList.add(ent);
jurzua
parents:
diff changeset
292 }
jurzua
parents:
diff changeset
293
jurzua
parents:
diff changeset
294 for(Entity ent : wrapper.getTargetsForSourceRelation(title, "was_created_in", "PLACE", 1)){
jurzua
parents:
diff changeset
295 //if(ent.isLightweight())
jurzua
parents:
diff changeset
296 // ent = wrapper.getEntityContent(ent);
jurzua
parents:
diff changeset
297 ent.setIsPublic(privacity);
jurzua
parents:
diff changeset
298 saveList.add(ent);
jurzua
parents:
diff changeset
299 }
jurzua
parents:
diff changeset
300 }
jurzua
parents:
diff changeset
301
jurzua
parents:
diff changeset
302 for(Entity ent : wrapper.getSourcesForTargetRelation(title, "is_alias_title_of", "ALIAS", -1)){
jurzua
parents:
diff changeset
303 //if(ent.isLightweight())
jurzua
parents:
diff changeset
304 // ent = wrapper.getEntityContent(ent);
jurzua
parents:
diff changeset
305 ent.setIsPublic(privacity);
jurzua
parents:
diff changeset
306 saveList.add(ent);
jurzua
parents:
diff changeset
307 }
jurzua
parents:
diff changeset
308
jurzua
parents:
diff changeset
309 return saveList;
jurzua
parents:
diff changeset
310 }
jurzua
parents:
diff changeset
311
jurzua
parents:
diff changeset
312
jurzua
parents:
diff changeset
313 /**
jurzua
parents:
diff changeset
314 * 437080
jurzua
parents:
diff changeset
315 * al-Taḏkiraẗ fī ʿilm al-hayʾaẗ
jurzua
parents:
diff changeset
316 * BIT(1)
jurzua
parents:
diff changeset
317 * create:
jurzua
parents:
diff changeset
318 * ALTER TABLE `openmind`.`node` ADD COLUMN `public` BIT(1) AFTER `possible_value`;
jurzua
parents:
diff changeset
319 * modify:
jurzua
parents:
diff changeset
320 * ALTER TABLE `openmind`.`node` MODIFY COLUMN `public` BIT(1) NOT NULL DEFAULT false;
jurzua
parents:
diff changeset
321 * @param witness
jurzua
parents:
diff changeset
322 * @param isPublic
jurzua
parents:
diff changeset
323 * @param wrapper
jurzua
parents:
diff changeset
324 * @return
jurzua
parents:
diff changeset
325 */
jurzua
parents:
diff changeset
326 public static List<Entity> changePrivacity4Witness(Entity witness, Boolean isPublic, WrapperService wrapper){
jurzua
parents:
diff changeset
327 List<Entity> saveList = new ArrayList<Entity>();
jurzua
parents:
diff changeset
328 /*
jurzua
parents:
diff changeset
329 if(witness.isLightweight()){
jurzua
parents:
diff changeset
330 witness = wrapper.getEntityContent(witness);
jurzua
parents:
diff changeset
331 }
jurzua
parents:
diff changeset
332 */
jurzua
parents:
diff changeset
333 boolean privacity = false;
jurzua
parents:
diff changeset
334 if(isPublic == null){
jurzua
parents:
diff changeset
335 privacity = !witness.getIsPublic();
jurzua
parents:
diff changeset
336 }else{
jurzua
parents:
diff changeset
337 privacity = isPublic;
jurzua
parents:
diff changeset
338 }
jurzua
parents:
diff changeset
339
jurzua
parents:
diff changeset
340 witness.setIsPublic(privacity);
jurzua
parents:
diff changeset
341 saveList.add(witness);
jurzua
parents:
diff changeset
342
jurzua
parents:
diff changeset
343 //changing references
jurzua
parents:
diff changeset
344 List<Entity> refEntities = wrapper.getSourcesForTargetRelation(witness.getId(), "is_reference_of", "REFERENCE", -1);
jurzua
parents:
diff changeset
345 for(Entity ref : refEntities){
jurzua
parents:
diff changeset
346 if(ref.isLightweight()){
jurzua
parents:
diff changeset
347 ref = wrapper.getEntityContent(ref);
jurzua
parents:
diff changeset
348 }
jurzua
parents:
diff changeset
349 ref.setIsPublic(privacity);
jurzua
parents:
diff changeset
350 saveList.add(ref);
jurzua
parents:
diff changeset
351 }
jurzua
parents:
diff changeset
352
jurzua
parents:
diff changeset
353 //only if the witness is done public, the related entities will be changed.
jurzua
parents:
diff changeset
354 if(privacity){
jurzua
parents:
diff changeset
355 List<Entity> list =
jurzua
parents:
diff changeset
356 wrapper.getTargetsForSourceRelation(witness.getId(),"is_part_of", "CODEX", 1);
jurzua
parents:
diff changeset
357 if (list.size() > 0) {
jurzua
parents:
diff changeset
358 Entity codex = list.get(0);
jurzua
parents:
diff changeset
359 codex.setIsPublic(privacity);
jurzua
parents:
diff changeset
360 saveList.add(codex);
jurzua
parents:
diff changeset
361
jurzua
parents:
diff changeset
362 list = wrapper.getTargetsForSourceRelation(codex.getId(), "is_part_of", "COLLECTION", 1);
jurzua
parents:
diff changeset
363 if (list.size() > 0) {
jurzua
parents:
diff changeset
364 Entity collection = list.get(0);
jurzua
parents:
diff changeset
365 collection.setIsPublic(privacity);
jurzua
parents:
diff changeset
366 saveList.add(collection);
jurzua
parents:
diff changeset
367
jurzua
parents:
diff changeset
368 list = wrapper.getTargetsForSourceRelation(collection.getId(), "is_part_of", "REPOSITORY", 1);
jurzua
parents:
diff changeset
369 if (list.size() > 0) {
jurzua
parents:
diff changeset
370 Entity repository = list.get(0);
jurzua
parents:
diff changeset
371 repository.setIsPublic(privacity);
jurzua
parents:
diff changeset
372 saveList.add(repository);
jurzua
parents:
diff changeset
373
jurzua
parents:
diff changeset
374 list = wrapper.getTargetsForSourceRelation(repository.getId(), "is_in", "PLACE", 1);
jurzua
parents:
diff changeset
375 if(list.size() > 0){
jurzua
parents:
diff changeset
376 Entity city = list.get(0);
jurzua
parents:
diff changeset
377 city.setIsPublic(privacity);
jurzua
parents:
diff changeset
378 saveList.add(city);
jurzua
parents:
diff changeset
379
jurzua
parents:
diff changeset
380 list = wrapper.getTargetsForSourceRelation(city.getId(), "is_part_of", "PLACE", 1);
jurzua
parents:
diff changeset
381 if(list.size() > 0){
jurzua
parents:
diff changeset
382 Entity country = list.get(0);
jurzua
parents:
diff changeset
383 country.setIsPublic(privacity);
jurzua
parents:
diff changeset
384 saveList.add(country);
jurzua
parents:
diff changeset
385 }
jurzua
parents:
diff changeset
386 }
jurzua
parents:
diff changeset
387 }
jurzua
parents:
diff changeset
388 }
jurzua
parents:
diff changeset
389 }
jurzua
parents:
diff changeset
390 }
jurzua
parents:
diff changeset
391
jurzua
parents:
diff changeset
392 return saveList;
jurzua
parents:
diff changeset
393 }
jurzua
parents:
diff changeset
394
jurzua
parents:
diff changeset
395 }