Mercurial > hg > ismi-richfaces
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 |
| rev | line source |
|---|---|
| 1 | 1 package de.mpiwg.itgroup.ismi.entry.utils; |
| 2 | |
| 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 | 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 | 10 |
| 11 import org.mpi.openmind.cache.WrapperService; | |
| 12 import org.mpi.openmind.repository.bo.Entity; | |
| 13 import org.mpi.openmind.repository.bo.Relation; | |
| 14 | |
| 15 public class PrivacityUtils { | |
| 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 | 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 | 217 public static List<Entity> changePrivacity4Person(Entity person, Boolean isPublic, WrapperService wrapper){ |
| 218 List<Entity> saveList = new ArrayList<Entity>(); | |
| 219 | |
| 220 if(person.isLightweight()){ | |
| 221 person = wrapper.getEntityContent(person); | |
| 222 } | |
| 223 | |
| 224 boolean privacity = false; | |
| 225 if(isPublic == null){ | |
| 226 privacity = !person.getIsPublic(); | |
| 227 }else{ | |
| 228 privacity = isPublic; | |
| 229 } | |
| 230 | |
| 231 person.setIsPublic(privacity); | |
| 232 saveList.add(person); | |
| 233 | |
| 234 List<Relation> relList = null; | |
| 235 //loading relations | |
| 236 if(privacity){ | |
| 237 relList = new ArrayList<Relation>(person.getSourceRelations()); | |
| 238 for (Relation rel : relList) { | |
| 239 String relName = rel.getOwnValue(); | |
| 240 if (relName.equals("was_born_in") || | |
| 241 relName.equals("lived_in") || | |
| 242 relName.equals("was_student_of") || | |
| 243 relName.equals("has_role") || | |
| 244 relName.equals("died_in")) { | |
| 245 Entity target = wrapper.getEntityById(rel.getTargetId()); | |
| 246 //target = wrapper.getEntityContent(target); | |
| 247 target.setIsPublic(privacity); | |
| 248 saveList.add(target); | |
| 249 } | |
| 250 } | |
| 251 } | |
| 252 | |
| 253 relList = new ArrayList<Relation>(person.getTargetRelations()); | |
| 254 for (Relation rel : relList) { | |
| 255 String relName = rel.getOwnValue(); | |
| 256 //title were be not included into this list | |
| 257 if (relName.equals("is_alias_name_of") || relName.equals("is_prime_alias_name_of")) { | |
| 258 Entity source = wrapper.getEntityById(rel.getSourceId()); | |
| 259 //source = wrapper.getEntityContent(source); | |
| 260 source.setIsPublic(privacity); | |
| 261 saveList.add(source); | |
| 262 } | |
| 263 } | |
| 264 | |
| 265 return saveList; | |
| 266 } | |
| 267 | |
| 268 public static List<Entity> changePrivacity4Title(Entity title, Boolean isPublic, WrapperService wrapper){ | |
| 269 List<Entity> saveList = new ArrayList<Entity>(); | |
| 270 | |
| 271 /* | |
| 272 if(title.isLightweight()){ | |
| 273 title = wrapper.getEntityContent(title); | |
| 274 }*/ | |
| 275 | |
| 276 boolean privacity = false; | |
| 277 if(isPublic == null){ | |
| 278 privacity = !title.getIsPublic(); | |
| 279 }else{ | |
| 280 privacity = isPublic; | |
| 281 } | |
| 282 | |
| 283 title.setIsPublic(privacity); | |
| 284 saveList.add(title); | |
| 285 | |
| 286 if(privacity){ | |
| 287 for(Entity ent : wrapper.getTargetsForSourceRelation(title, "has_subject", "SUBJECT", 1)){ | |
| 288 //if(ent.isLightweight()) | |
| 289 // ent = wrapper.getEntityContent(ent); | |
| 290 ent.setIsPublic(privacity); | |
| 291 saveList.add(ent); | |
| 292 } | |
| 293 | |
| 294 for(Entity ent : wrapper.getTargetsForSourceRelation(title, "was_created_in", "PLACE", 1)){ | |
| 295 //if(ent.isLightweight()) | |
| 296 // ent = wrapper.getEntityContent(ent); | |
| 297 ent.setIsPublic(privacity); | |
| 298 saveList.add(ent); | |
| 299 } | |
| 300 } | |
| 301 | |
| 302 for(Entity ent : wrapper.getSourcesForTargetRelation(title, "is_alias_title_of", "ALIAS", -1)){ | |
| 303 //if(ent.isLightweight()) | |
| 304 // ent = wrapper.getEntityContent(ent); | |
| 305 ent.setIsPublic(privacity); | |
| 306 saveList.add(ent); | |
| 307 } | |
| 308 | |
| 309 return saveList; | |
| 310 } | |
| 311 | |
| 312 | |
| 313 /** | |
| 314 * 437080 | |
| 315 * al-Taḏkiraẗ fī ʿilm al-hayʾaẗ | |
| 316 * BIT(1) | |
| 317 * create: | |
| 318 * ALTER TABLE `openmind`.`node` ADD COLUMN `public` BIT(1) AFTER `possible_value`; | |
| 319 * modify: | |
| 320 * ALTER TABLE `openmind`.`node` MODIFY COLUMN `public` BIT(1) NOT NULL DEFAULT false; | |
| 321 * @param witness | |
| 322 * @param isPublic | |
| 323 * @param wrapper | |
| 324 * @return | |
| 325 */ | |
| 326 public static List<Entity> changePrivacity4Witness(Entity witness, Boolean isPublic, WrapperService wrapper){ | |
| 327 List<Entity> saveList = new ArrayList<Entity>(); | |
| 328 /* | |
| 329 if(witness.isLightweight()){ | |
| 330 witness = wrapper.getEntityContent(witness); | |
| 331 } | |
| 332 */ | |
| 333 boolean privacity = false; | |
| 334 if(isPublic == null){ | |
| 335 privacity = !witness.getIsPublic(); | |
| 336 }else{ | |
| 337 privacity = isPublic; | |
| 338 } | |
| 339 | |
| 340 witness.setIsPublic(privacity); | |
| 341 saveList.add(witness); | |
| 342 | |
| 343 //changing references | |
| 344 List<Entity> refEntities = wrapper.getSourcesForTargetRelation(witness.getId(), "is_reference_of", "REFERENCE", -1); | |
| 345 for(Entity ref : refEntities){ | |
| 346 if(ref.isLightweight()){ | |
| 347 ref = wrapper.getEntityContent(ref); | |
| 348 } | |
| 349 ref.setIsPublic(privacity); | |
| 350 saveList.add(ref); | |
| 351 } | |
| 352 | |
| 353 //only if the witness is done public, the related entities will be changed. | |
| 354 if(privacity){ | |
| 355 List<Entity> list = | |
| 356 wrapper.getTargetsForSourceRelation(witness.getId(),"is_part_of", "CODEX", 1); | |
| 357 if (list.size() > 0) { | |
| 358 Entity codex = list.get(0); | |
| 359 codex.setIsPublic(privacity); | |
| 360 saveList.add(codex); | |
| 361 | |
| 362 list = wrapper.getTargetsForSourceRelation(codex.getId(), "is_part_of", "COLLECTION", 1); | |
| 363 if (list.size() > 0) { | |
| 364 Entity collection = list.get(0); | |
| 365 collection.setIsPublic(privacity); | |
| 366 saveList.add(collection); | |
| 367 | |
| 368 list = wrapper.getTargetsForSourceRelation(collection.getId(), "is_part_of", "REPOSITORY", 1); | |
| 369 if (list.size() > 0) { | |
| 370 Entity repository = list.get(0); | |
| 371 repository.setIsPublic(privacity); | |
| 372 saveList.add(repository); | |
| 373 | |
| 374 list = wrapper.getTargetsForSourceRelation(repository.getId(), "is_in", "PLACE", 1); | |
| 375 if(list.size() > 0){ | |
| 376 Entity city = list.get(0); | |
| 377 city.setIsPublic(privacity); | |
| 378 saveList.add(city); | |
| 379 | |
| 380 list = wrapper.getTargetsForSourceRelation(city.getId(), "is_part_of", "PLACE", 1); | |
| 381 if(list.size() > 0){ | |
| 382 Entity country = list.get(0); | |
| 383 country.setIsPublic(privacity); | |
| 384 saveList.add(country); | |
| 385 } | |
| 386 } | |
| 387 } | |
| 388 } | |
| 389 } | |
| 390 } | |
| 391 | |
| 392 return saveList; | |
| 393 } | |
| 394 | |
| 395 } |
