diff src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentCodexBean.java @ 161:8049becb05ca

New ALIAS is_alias_identifier_of CODEX/WITNESS for diverse catalog numbers.
author Robert Casties <casties@mpiwg-berlin.mpg.de>
date Thu, 19 Apr 2018 20:35:12 +0200
parents 502ae5b1a07d
children
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentCodexBean.java	Fri Apr 13 12:58:36 2018 +0200
+++ b/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentCodexBean.java	Thu Apr 19 20:35:12 2018 +0200
@@ -32,7 +32,8 @@
 
 	private List<Entity> witnessInCurrentCodex;
 	private boolean showWitnessInCurrentCodex;
-	
+ 
+	private EntityList aliasIdList;
 	private EntityList ownedByPeople;
 	private EntityList readByPeople;
 	
@@ -51,7 +52,7 @@
 			// source relations
 			new String[]{"is_part_of", "is_alias_of", "owned_by", "read_by"},
 			// target relations
-			new String[]{"is_alias_of", "is_reference_of"});
+			new String[]{"is_alias_of", "is_reference_of", is_alias_identifier_of});
 
 	
 	public CurrentCodexBean() {
@@ -70,6 +71,8 @@
 		super.reset();
 		this.entity = new Entity(Node.TYPE_ABOX, CODEX, false);
 		
+		this.aliasIdList = new EntityList(ALIAS, "alias", getWrapper(), getUserName());
+	      
 		this.ownedByPeople = new EntityList(PERSON, "name_translit", true);
 		this.readByPeople = new EntityList(PERSON, "name_translit", true);
 		
@@ -140,6 +143,11 @@
 					this.isAlias = false;
 				}
 				
+                for(Relation rel : getWrapper().getTargetRelations(codex, is_alias_identifier_of, ALIAS, -1)) {
+                    Entity alias = getWrapper().getEntityById(rel.getSourceId());
+                    this.aliasIdList.add(alias);
+                }
+                
 				for(Relation rel : getWrapper().getSourceRelations(codex, owned_by, PERSON, -1)) {
 					this.ownedByPeople.add(getWrapper().getEntityById(rel.getTargetId()), rel.getAttributeByName("date"));
 				}
@@ -244,22 +252,22 @@
 
 			this.entity.replaceUniqueSourceRelation(this.getCollectionLo().entity, COLLECTION, is_part_of);
 			
-			// CODEX -> owner_by (manyToMany) -> PERSON
-			this.entity.removeAllSourceRelationsByName(owned_by);
-			
-			// CODEX -> read_by (manyToMany) -> PERSON
-			this.entity.removeAllSourceRelationsByName("read_by");
-			
-			//REFERENCE -> is_reference_of -> THIS
-			//this.entity = this.prepareReferencesToSave(this.entity);
-			this.saveReferences();		
-
+            // ALIAS -> is_identifier_of -> CODEX
+            replaceMultipleTargetRelations(entity, aliasIdList.getEntities(), ALIAS, is_alias_identifier_of);
+            
 			// CODEX -> owned_by -> PERSON
 			replaceMultipleSourceRelations(entity, ownedByPeople.getEntities(), PERSON, owned_by);
+            
 			// CODEX -> read_by -> PERSON
 			replaceMultipleSourceRelations(entity, readByPeople.getEntities(), PERSON, "read_by");
 			
 			/* TODO: currently ignoring date on relations
+            // CODEX -> owner_by (manyToMany) -> PERSON
+            this.entity.removeAllSourceRelationsByName(owned_by);
+            
+            // CODEX -> read_by (manyToMany) -> PERSON
+            this.entity.removeAllSourceRelationsByName("read_by");
+            
 			for (Entity owner : this.ownedByPeople.getEntities()) {
 				if (owner.isLightweight()) {
 					owner = getWrapper().getEntityByIdWithContent(owner.getId());
@@ -279,6 +287,11 @@
 			}
 			*/
 
+			//REFERENCE -> is_reference_of -> THIS
+            //this.entity = this.prepareReferencesToSave(this.entity);
+            this.saveReferences();      
+
+
 			// save this entity
 			this.entity = getWrapper().saveEntity(this.entity, getSessionUser().getEmail(), editCodexIntent);
 			
@@ -356,7 +369,21 @@
 		}
 	}
 	
-	public EntityList getOwnedByPeople() {
+	/**
+     * @return the aliasIdList
+     */
+    public EntityList getAliasIdList() {
+        return aliasIdList;
+    }
+
+    /**
+     * @param aliasIdList the aliasIdList to set
+     */
+    public void setAliasIdList(EntityList aliasIdList) {
+        this.aliasIdList = aliasIdList;
+    }
+
+    public EntityList getOwnedByPeople() {
 		return ownedByPeople;
 	}