if (annotation instanceof IEntityContainer<?>) {
IEntityContainer<?> container = (IEntityContainer<?>) annotation;
if (container.isMarkedAsNew() || container.isDirty()) {
- persistenceService.save(container.getEntity()); // save
+ Object entity = persistenceService.save(container.getEntity()); // save
+ container.setEntity(entity);
container.setDirty(false);
container.markAsNew(false);
}
// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
* @return a T object.
*/
T getEntity();
-
+
+ void setEntity(Object entity);
+
/**
* <p>getEditableText</p>
*
* @return a {@link java.lang.String} object.
*/
String getEditableText();
-
+
/**
* <p>getAttachedEntities</p>
*
* @return a {@link java.util.Set} object.
*/
Set<T> getAttachedEntities();
-
+
/**
* <p>markAsMerged</p>
*
* @param mergeTarget a T object.
*/
void markAsMerged(T mergeTarget);
-
+
/**
* <p>markAsDeleted</p>
*/
void markAsDeleted();
-
+
/**
* <p>markAsNew</p>
*
* @param isNew a boolean.
*/
void markAsNew(boolean isNew);
-
+
/**
* <p>isMarkedAsMerged</p>
*
* @return a boolean.
*/
boolean isMarkedAsMerged();
-
+
/**
* <p>isMarkedAsDeleted</p>
*
* @return a boolean.
*/
boolean isMarkedAsDeleted();
-
+
/**
* <p>isMarkedAsNew</p>
*
// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
* @version 1.0
*/
public interface IEntityPersistenceService<T> {
-
+
/**
* <p>create</p>
*
* @param entity a {@link java.lang.Object} object.
* @return a boolean.
*/
- boolean create(T entity);
-
+ T create(T entity);
+
/**
* <p>save</p>
*
* @param entity a {@link java.lang.Object} object.
* @return a boolean.
*/
- boolean save(T entity);
-
+ T save(T entity);
+
/**
* <p>merge</p>
*
* @return a boolean.
*/
boolean merge(T entity, T mergeTarget);
-
+
/**
* <p>delete</p>
*
* @param entity a {@link java.lang.Object} object.
* @return a boolean.
- * @throws ReferencedObjectUndeletableException
+ * @throws ReferencedObjectUndeletableException
*/
boolean delete(T entity) throws ReferencedObjectUndeletableException;
}
// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
/** Constant <code>TYPE_GENERIC="Annotation.TYPE_UNKNOWN"</code> */
public static final String TYPE_GENERIC = Annotation.TYPE_UNKNOWN;
-
+
private T entity;
private ILineDisplayStrategy lineDisplayStrategy;
private boolean markedAsNew;
private T mergeTarget;
-
+
/**
* <p>Constructor for LineAnnotation.</p>
*
this.lineDisplayStrategy = lineDisplayStrategy;
setType(TYPE_GENERIC);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.text.source.Annotation#getText()
*/
public String getText() {
return getEditableText();
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.text.source.Annotation#setText(java.lang.String)
*/
@Override
public void setText(String text) {
lineDisplayStrategy.setText(text, entity);
- dirty = true;
+ dirty = true;
super.setText(text);
}
-
+
/** {@inheritDoc} */
@Override
public String toString() {
// For debugging
return getText();
}
-
+
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#getAttachedEntities()
*/
*
* @return a {@link java.util.Set} object.
*/
- public Set getAttachedEntities() {
+ @Override
+ public Set getAttachedEntities() {
// TODO Auto-generated method stub
return null;
}
*
* @return a T object.
*/
- public T getEntity() {
+ @Override
+ public T getEntity() {
return entity;
}
*
* @return a {@link java.lang.String} object.
*/
- public String getEditableText() {
+ @Override
+ public String getEditableText() {
return lineDisplayStrategy.getText(entity);
}
*
* @return a T object.
*/
- public T getMergeTarget() {
+ @Override
+ public T getMergeTarget() {
return mergeTarget;
}
*
* @return a boolean.
*/
- public boolean isMarkedAsDeleted() {
+ @Override
+ public boolean isMarkedAsDeleted() {
return super.isMarkedDeleted();
}
*
* @return a boolean.
*/
- public boolean isMarkedAsMerged() {
+ @Override
+ public boolean isMarkedAsMerged() {
return markedAsMerged;
}
*
* @return a boolean.
*/
- public boolean isMarkedAsNew() {
+ @Override
+ public boolean isMarkedAsNew() {
return markedAsNew;
}
/**
* <p>markAsDeleted</p>
*/
- public void markAsDeleted() {
+ @Override
+ public void markAsDeleted() {
super.markDeleted(true);
if (!isMarkedAsMerged()) {
lineDisplayStrategy.setStatusMessage(entity + " deleted.", entity);
*
* @param mergeTarget a T object.
*/
- public void markAsMerged(T mergeTarget) {
+ @Override
+ public void markAsMerged(T mergeTarget) {
this.mergeTarget = mergeTarget;
markedAsMerged = true;
lineDisplayStrategy.setStatusMessage("'" + entity + "' merged into '" + mergeTarget + "'.", entity);
* @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#markAsNew()
*/
/** {@inheritDoc} */
- public void markAsNew(boolean isNew) {
+ @Override
+ public void markAsNew(boolean isNew) {
markedAsNew = isNew;
lineDisplayStrategy.setStatusMessage("New entity created.", entity);
}
* @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#setDirty(boolean)
*/
/** {@inheritDoc} */
- public void setDirty(boolean dirty) {
+ @Override
+ public void setDirty(boolean dirty) {
this.dirty = dirty;
}
*
* @return a boolean.
*/
- public boolean isDirty() {
+ @Override
+ public boolean isDirty() {
return dirty;
}
public String getHoverText() {
return lineDisplayStrategy.getHoverText(entity);
}
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityContainer#setEntity(java.lang.Object)
+ */
+ @Override
+ public void setEntity(Object entity) {
+ this.entity = (T) entity;
+ }
}
/** {@inheritDoc} */
@Override
- public boolean create(T entity) {
+ public T create(T entity) {
return save(entity);
}
return model;
}
-
+ protected boolean replaceInModel(T entity) {
+ int index = model.indexOf(entity);
+ if(index >= 0) {
+ model.set(index, entity);
+ return true;
+ } else {
+ return false;
+ }
+ }
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
}
@Override
- public boolean save(TeamOrPersonBase entity) {
+ public TeamOrPersonBase save(TeamOrPersonBase entity) {
if(CdmStore.getCurrentSessionManager().isRemoting()) {
- return CdmStore.getService(IAgentService.class).merge(entity) != null;
+ return (TeamOrPersonBase) CdmStore.getService(IAgentService.class).merge(entity);
} else {
- return CdmStore.getService(IAgentService.class).saveOrUpdate(entity) != null;
+ CdmStore.getService(IAgentService.class).saveOrUpdate(entity) ;
+ return entity;
}
}
* @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#save(java.lang.Object)
*/
@Override
- public boolean save(Group entity) {
+ public Group save(Group entity) {
if(CdmStore.getCurrentSessionManager().isRemoting()) {
- return CdmStore.getService(IGroupService.class).merge(entity) != null;
+ return CdmStore.getService(IGroupService.class).merge(entity) ;
} else {
- return CdmStore.getService(IGroupService.class).saveOrUpdate(entity) != null;
+ CdmStore.getService(IGroupService.class).saveOrUpdate(entity);
+ return entity;
}
}
/** {@inheritDoc} */
@Override
- public boolean save(TaxonNameBase entity) {
+ public TaxonNameBase save(TaxonNameBase entity) {
if(CdmStore.getCurrentSessionManager().isRemoting()) {
- return CdmStore.getService(INameService.class).merge(entity) != null;
+ return CdmStore.getService(INameService.class).merge(entity) ;
} else {
- return CdmStore.getService(INameService.class).saveOrUpdate(entity) != null;
+ CdmStore.getService(INameService.class).saveOrUpdate(entity);
+ return entity;
}
}
*/
/** {@inheritDoc} */
@Override
- public boolean save(NameRelationship entity) {
+ public NameRelationship save(NameRelationship entity) {
// TODO Auto-generated method stub
- return false;
+ return null;
}
/* (non-Javadoc)
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
+import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorSortProvider;
import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.OccurrenceCreator;
*/
/** {@inheritDoc} */
@Override
- public boolean save(SpecimenOrObservationBase entity) {
+ public SpecimenOrObservationBase<IIdentifiableEntityCacheStrategy> save(SpecimenOrObservationBase entity) {
if(CdmStore.getCurrentSessionManager().isRemoting()) {
- return CdmStore.getService(IOccurrenceService.class).merge(entity) != null;
+ return CdmStore.getService(IOccurrenceService.class).merge(entity) ;
} else {
- return CdmStore.getService(IOccurrenceService.class).save(entity) != null;
+ CdmStore.getService(IOccurrenceService.class).save(entity);
+ return entity;
}
}
/** {@inheritDoc} */
@Override
- public boolean save(Reference entity) {
+ public Reference save(Reference entity) {
if(CdmStore.getCurrentSessionManager().isRemoting()) {
- return CdmStore.getService(IReferenceService.class).merge(entity) != null;
+ return CdmStore.getService(IReferenceService.class).merge(entity);
} else {
- return CdmStore.getService(IReferenceService.class).saveOrUpdate(entity) != null;
+ CdmStore.getService(IReferenceService.class).saveOrUpdate(entity);
+ return entity;
}
}
return false;\r
}\r
@Override\r
- public boolean save(TaxonBase entity) {\r
+ public TaxonBase save(TaxonBase entity) {\r
if(CdmStore.getCurrentSessionManager().isRemoting()) {\r
- return CdmStore.getService(ITaxonService.class).merge(entity) != null;\r
+ return CdmStore.getService(ITaxonService.class).merge(entity);\r
} else {\r
- return CdmStore.getService(ITaxonService.class).saveOrUpdate(entity) != null;\r
+ CdmStore.getService(ITaxonService.class).saveOrUpdate(entity);\r
+ return entity;\r
}\r
}\r
\r
* @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#save(java.lang.Object)
*/
@Override
- public boolean save(User entity) {
+ public User save(User entity) {
if(CdmStore.getCurrentSessionManager().isRemoting()) {
- return CdmStore.getService(IUserService.class).merge(entity) != null;
+ return CdmStore.getService(IUserService.class).merge(entity);
} else {
- return CdmStore.getService(IUserService.class).saveOrUpdate(entity) != null;
+ CdmStore.getService(IUserService.class).saveOrUpdate(entity);
+ return entity;
}
}