Changeset 25:2140ef107551 in AnnotationManagerN4J
- Timestamp:
- Sep 24, 2012, 9:36:33 AM (12 years ago)
- Branch:
- default
- Location:
- src/main/java/de/mpiwg/itgroup/annotations
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java
r24 r25 176 176 } 177 177 return members; 178 } 179 180 /** 181 * Add Person newMember to Group group. 182 * 183 * @param group 184 * @param member 185 */ 186 public Person addGroupMember(Group group, Person member) { 187 Node gn = getActorNode(group); 188 Node pn = getActorNode(member); 189 Person addedMember = null; 190 if (gn != null && pn != null) { 191 getOrCreateRelation(pn, RelationTypes.MEMBER_OF, gn); 192 addedMember = member; 193 } 194 return addedMember; 195 } 196 197 /** 198 * Delete Person oldMember from Group group. 199 * 200 * @param group 201 * @param member 202 */ 203 public void deleteGroupMember(Group group, Person member) { 204 Node gn = getActorNode(group); 205 Iterable<Relationship> rels = gn.getRelationships(RelationTypes.MEMBER_OF); 206 for (Relationship rel : rels) { 207 Node mn = rel.getStartNode(); 208 if (mn.equals(member)) { 209 rel.delete(); 210 // there should be only one 211 break; 212 } 213 } 178 214 } 179 215 -
src/main/java/de/mpiwg/itgroup/annotations/restlet/annotations_ui/GroupMembersResource.java
r24 r25 48 48 result += "<p>Members:</p>\n"; 49 49 result += "<table>"; 50 result += String.format("<form method=\"post\" action=\"%s\">", thisUrl); 50 51 List<Person> members = store.getMembersOfGroup(group); 51 52 for (Person p : members) { 52 53 result += String.format("<tr><td>%s</td><td>(%s)</td>", p.getName(), p.getIdString()); 53 //result += String.format("<td></td></tr>\n", p.getName(), p.getIdString());54 result += String.format("<td><input type=\"submit\" name=\"del_member\" value=\"delete:%s\"></td></tr>\n", p.getIdString()); 54 55 } 55 56 result += "</table>\n"; 57 result += "</form>\n"; 56 58 result += String.format("<form method=\"post\" action=\"%s\">\n", thisUrl); 57 59 result += "<p>Add new member: <select name=\"add_member\">\n"; … … 85 87 return null; 86 88 } 87 89 if (addMemberId != null) { 90 logger.debug("adding member: "+addMemberId); 91 Person member = new Person(addMemberId); 92 store.addGroupMember(group, member); 93 } else if (delMemberId != null) { 94 if (delMemberId.startsWith("delete:")) { 95 delMemberId = delMemberId.substring(7); 96 } 97 logger.debug("deleting member: "+delMemberId); 98 Person member = new Person(delMemberId); 99 store.deleteGroupMember(group, member); 100 } 88 101 // return 303: see other 89 102 setStatus(Status.REDIRECTION_SEE_OTHER);
Note: See TracChangeset
for help on using the changeset viewer.