Mercurial > hg > ismi-richfaces
view src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentDigitalizationBean.java @ 166:caf1aa768457
updated public_manifest_url in DIGITALIZATION form.
author | Robert Casties <casties@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 29 May 2018 21:16:46 +0200 |
parents | 1326182855ef |
children |
line wrap: on
line source
package de.mpiwg.itgroup.ismi.entry.beans; import java.io.Serializable; import java.util.List; import javax.faces.event.ActionEvent; import org.apache.log4j.Logger; import org.mpi.openmind.repository.bo.Entity; import org.mpi.openmind.repository.bo.Node; import org.mpi.openmind.repository.services.utils.EditIntent; import org.mpi.openmind.security.bo.User; import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject; public class CurrentDigitalizationBean extends CodexEditorTemplate implements Serializable{ private static final long serialVersionUID = 4910425502556948216L; private static Logger logger = Logger.getLogger(CurrentDigitalizationBean.class); /** intent to edit all attributes and relations in the form */ public static EditIntent editDigitalizationIntent = new EditIntent( AbstractISMIBean.DIGITALIZATION, // attributes new String[]{"name", "num_files", "public_manifest_url", "public"}, // source relations new String[]{"is_digitalization_of"}, // target relations new String[]{}); public CurrentDigitalizationBean(){ super(); this.entity = new Entity(Node.TYPE_ABOX, DIGITALIZATION, false); setDefObjectClass(DIGITALIZATION); } @Override public void reset(){ super.reset(); this.entity = new Entity(Node.TYPE_ABOX, DIGITALIZATION, false); } @Override public void setEntity(Entity digi){ this.reset(); this.entity = digi; if(this.entity.isPersistent()){ if (entity.isLightweight()) { entity = getWrapper().getEntityContent(digi); } } this.loadAttributes(this.entity); List<Entity> list = getWrapper().getTargetsForSourceRelation(entity, is_digitalization_of, CODEX, -1); if(list.size() > 0){ this.setCodex(list.get(0)); } } public void setCodex(Entity codex){ this.getCodexLo().setEntityAndAttributeName(codex, "identifier"); if(this.getCodexLo().entity != null && this.getCodexLo().entity.isPersistent()){ List<Entity> list = getWrapper().getTargetsForSourceRelation(codex, is_part_of, COLLECTION, 1); if(list.size() > 0){ this.setCollection(list.get(0)); } } } public void unsetCodex(ActionEvent event){ this.setCodexLo(new ListenerObject()); //this.getCodexLo().setEntityAndAttribute(null, null); } @Override public String save() { super.save(); try { User user = getSessionUser(); this.entity = this.updateEntityAttributes(this.entity); // DIGITALIZATION -> is_digitalization_of -> CODEX this.entity.replaceUniqueSourceRelation(getCodexLo().entity, CODEX, is_digitalization_of); // save this entity this.entity = getWrapper().saveEntity(this.entity, user.getEmail(), editDigitalizationIntent); this.setEntity(this.entity); logger.info("Entity saved - Time = " + (System.currentTimeMillis() - start) + ", " + entity); this.printSuccessSavingEntity(); } catch (Exception e) { logger.error(e.getMessage(), e); this.printInternalError(e); } saveEnd(); return PAGE_EDITOR; } }