66
|
1 package org.mpi.openmind.repository.services.utils;
|
|
2
|
|
3 import java.util.HashSet;
|
|
4 import java.util.Set;
|
|
5
|
|
6 /**
|
|
7 * Class documenting the parts (attributes, relations) if an Entity that may be
|
|
8 * edited.
|
|
9 *
|
|
10 * @author casties
|
|
11 *
|
|
12 */
|
|
13 public class EditIntent {
|
|
14 String modifiedEntity;
|
|
15 Set<String> modifiedAttributes;
|
|
16 Set<String> modifiedSourceRelations;
|
|
17 Set<String> modifiedTargetRelations;
|
|
18
|
|
19 /**
|
|
20 * Creates an EditIntent with the given attribute and relation names.
|
|
21 *
|
|
22 * @param modifiedEntity
|
|
23 * @param modifiedAttributes
|
|
24 * @param modifiedSourceRelations
|
|
25 * @param modifiedTargetRelations
|
|
26 */
|
|
27 public EditIntent(String modifiedEntity, Set<String> modifiedAttributes, Set<String> modifiedSourceRelations,
|
|
28 Set<String> modifiedTargetRelations) {
|
|
29 super();
|
|
30 this.modifiedEntity = modifiedEntity;
|
|
31 this.modifiedAttributes = modifiedAttributes;
|
|
32 this.modifiedSourceRelations = modifiedSourceRelations;
|
|
33 this.modifiedTargetRelations = modifiedTargetRelations;
|
|
34 }
|
|
35
|
|
36 /**
|
|
37 * Creates an EditIntent with the given attribute and relation names.
|
|
38 *
|
|
39 * @param modifiedEntity
|
|
40 * @param modifiedAttributes
|
|
41 * @param modifiedSourceRelations
|
|
42 * @param modifiedTargetRelations
|
|
43 */
|
|
44 public EditIntent(String modifiedEntity, String[] modifiedAttributes, String[] modifiedSourceRelations, String[] modifiedTargetRelations) {
|
|
45 super();
|
|
46 this.modifiedEntity = modifiedEntity;
|
|
47 this.modifiedAttributes = new HashSet<String>();
|
|
48 for (String s : modifiedAttributes) {
|
|
49 this.modifiedAttributes.add(s);
|
|
50 }
|
|
51
|
|
52 this.modifiedSourceRelations = new HashSet<String>();
|
|
53 for (String s : modifiedSourceRelations) {
|
|
54 this.modifiedSourceRelations.add(s);
|
|
55 }
|
|
56
|
|
57 this.modifiedTargetRelations = new HashSet<String>();
|
|
58 for (String s : modifiedTargetRelations) {
|
|
59 this.modifiedTargetRelations.add(s);
|
|
60 }
|
|
61 }
|
|
62
|
|
63 /**
|
|
64 * Returns if the modification of the Entity with the given name is intended.
|
|
65 *
|
|
66 * @param name
|
|
67 * @return
|
|
68 */
|
|
69 public boolean isEntModificationIntended(String name) {
|
|
70 return modifiedEntity.equals(name);
|
|
71 }
|
|
72
|
|
73 /**
|
|
74 * Returns if the modification of the Attribute with the given name is intended.
|
|
75 *
|
|
76 * @param name
|
|
77 * @return
|
|
78 */
|
|
79 public boolean isAttModificationIntended(String name) {
|
|
80 return modifiedAttributes.contains(name);
|
|
81 }
|
|
82
|
|
83 /**
|
|
84 * Returns if the modification of the Relation with the given name is intended.
|
|
85 *
|
|
86 * @param name
|
|
87 * @return
|
|
88 */
|
|
89 public boolean isSrcRelModificationIntended(String name) {
|
|
90 return modifiedSourceRelations.contains(name);
|
|
91 }
|
|
92
|
|
93 /**
|
|
94 * Returns if the modification of the Relation with the given name is intended.
|
|
95 *
|
|
96 * @param name
|
|
97 * @return
|
|
98 */
|
|
99 public boolean isTarRelModificationIntended(String name) {
|
|
100 return modifiedTargetRelations.contains(name);
|
|
101 }
|
|
102 }
|