}
public void dispose() {
+ CacheManager.create().removeCache(cache.getName());
cache.dispose();
}
import java.util.TreeMap;
import java.util.TreeSet;
+import org.hibernate.collection.internal.PersistentBag;
import org.hibernate.collection.internal.PersistentList;
import org.hibernate.collection.internal.PersistentMap;
import org.hibernate.collection.internal.PersistentSet;
if(pc instanceof PersistentSortedSet) {
return new TreeSet((Set)pc);
}
- if(pc instanceof PersistentList) {
+ if(pc instanceof PersistentList || pc instanceof PersistentBag) {
return new ArrayList((List)pc);
}
if(pc instanceof PersistentMap || pc instanceof PersistentMultiLanguageText) {
//Object obj = ProxyUtils.deproxy(cachedCommonService.initializeCollection(this));
Object obj = ProxyUtils.deproxy(cachedCommonService.initializeCollection(cdmBase.getUuid(), fieldName));
+ if(ProxyUtils.isProxy(obj)) {
+ throw new HibernateException("Persistent Collection initialized but is still a proxy");
+ }
afterInitialize();
Class<?> clazz = getClass();
import eu.etaxonomy.cdm.api.application.CdmApplicationRemoteConfiguration;
import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.taxeditor.remoting.cache.ProxyUtils;
import eu.etaxonomy.taxeditor.service.ICachedCommonService;
/**
}
CdmBase cdmBase = cachedCommonService.find(clazz,classid);
+ if(ProxyUtils.isProxy(cdmBase)) {
+ throw new HibernateException("CdmBase Object initialized but is still a proxy");
+ }
setImplementation(cdmBase);
}
return defaultService.merge(arg0);
}
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.cdm.api.service.IOccurrenceService#deleteDerivateHierarchy(java.util.UUID, eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator)
+ */
+ @Override
+ public DeleteResult deleteDerivateHierarchy(UUID arg0, SpecimenDeleteConfigurator arg1) {
+ return defaultService.deleteDerivateHierarchy(arg0, arg1);
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.cdm.api.service.IOccurrenceService#deleteSingleRead(java.util.UUID, java.util.UUID)
+ */
+ @Override
+ public DeleteResult deleteSingleRead(UUID arg0, UUID arg1) {
+ return defaultService.deleteSingleRead(arg0, arg1);
+ }
+
}
import java.util.Collection;
import java.util.HashSet;
+import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.EditorPart;
+import eu.etaxonomy.cdm.api.application.CdmChangeEvent;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateContentProvider;
import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider;
*/
public class DerivateView extends EditorPart implements IPartContentHasFactualData, IDirtyMarkable,
IConversationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, IPartContentHasMedia,
- ISelectionChangedListener, IPostOperationEnabled {
+ ISelectionChangedListener, IPostOperationEnabled , ICdmEntitySessionEnabled {
public static final String ID = "eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView";
private ISelection selection = null;
+ private final ICdmEntitySession cdmEntitySession;
+
+ private DerivateContentProvider contentProvider;
+
/**
* Default constructor
*/
public DerivateView() {
+ cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
}
/* (non-Javadoc)
@Override
public void createPartControl(Composite parent) {
viewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION));
- viewer.setContentProvider(new DerivateContentProvider());
+ contentProvider = new DerivateContentProvider();
+ viewer.setContentProvider(contentProvider);
labelProvider = new DerivateLabelProvider();
labelProvider.setConversation(conversation);
viewer.setLabelProvider(labelProvider);
// commit the conversation and start a new transaction immediately
conversation.commit(true);
+ CdmStore.getService(IOccurrenceService.class).merge(getRootEntities());
monitor.worked(1);
this.setDirty(false);
if(!conversation.isBound()){
conversation.bind();
}
+ cdmEntitySession.bind();
}
/* (non-Javadoc)
return true;
}
+ @Override
+ public void dispose() {
+ cdmEntitySession.dispose();
+ super.dispose();
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.cdm.api.application.ICdmChangeListener#onChange(eu.etaxonomy.cdm.api.application.CdmChangeEvent)
+ */
+ @Override
+ public void onChange(CdmChangeEvent event) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getCdmEntitySession()
+ */
+ @Override
+ public ICdmEntitySession getCdmEntitySession() {
+ return cdmEntitySession;
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
+ */
+ @Override
+ public List<SpecimenOrObservationBase> getRootEntities() {
+ return contentProvider.getRootElements();
+ }
+
}
import org.eclipse.ui.actions.CompoundContributionItem;
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeCacheStrategy;
+import eu.etaxonomy.cdm.api.service.IOccurrenceService;
import eu.etaxonomy.cdm.model.media.Media;
import eu.etaxonomy.cdm.model.molecular.DnaSample;
import eu.etaxonomy.cdm.model.molecular.Sequence;
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.ui.dialog.selection.MediaSelectionDialog;
/**
specimenOrObservationBase.addDerivationEvent(DerivationEvent.NewSimpleInstance(specimenOrObservationBase, mediaSpecimen, derivationEventType));
mediaSpecimen.setCacheStrategy(new DerivedUnitFacadeCacheStrategy());
mediaSpecimen.getTitleCache(); //update title cache
+ CdmStore.getService(IOccurrenceService.class).merge(specimenOrObservationBase);
}
//refresh view
derivateView = (DerivateView) AbstractUtility.getActivePart();
}
if(derivateView!=null){
+
derivateView.getConversationHolder().commit();
derivateView.refreshTree(mediaSpecimen);
}
//refresh view
if(derivateView!=null){
+ CdmStore.getService(IOccurrenceService.class).merge((SpecimenOrObservationBase) selectedDerivate);
derivateView.getConversationHolder().commit();
derivateView.refreshTree(createdElement);
}
&& treeNode.getValue().equals(element)
&& treeNode.getParent()!=null
&& treeNode.getParent().getValue() instanceof Sequence){
- deleteResult = CdmStore.getService(IOccurrenceService.class).deleteSingleRead((SingleRead)element, (Sequence) treeNode.getParent().getValue());
+ deleteResult = CdmStore.getService(IOccurrenceService.class).deleteSingleRead(((SingleRead)element).getUuid(),
+ ((Sequence) treeNode.getParent().getValue()).getUuid());
}
else{
- deleteResult = CdmStore.getService(IOccurrenceService.class).deleteDerivateHierarchy(element, deleteConfigurator);
+ deleteResult = CdmStore.getService(IOccurrenceService.class).deleteDerivateHierarchy(element.getUuid(), deleteConfigurator);
}
if(deleteResult.isOk()){
if(getPostOperationEnabled() instanceof DerivateView){
public class DerivateContentProvider implements ITreeContentProvider {
+ List<TreeNode> rootNodes;
+
@Override
public void dispose() {
// TODO Auto-generated method stub
}
+ public List<SpecimenOrObservationBase> getRootElements() {
+ List<SpecimenOrObservationBase> elements = new ArrayList<SpecimenOrObservationBase>();
+
+ if(rootNodes != null) {
+ for(TreeNode node : rootNodes) {
+ elements.add((SpecimenOrObservationBase)node.getValue());
+ }
+ }
+ return elements;
+ }
+
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
@Override
public Object[] getElements(Object inputElement) {
- List<TreeNode> rootElements = new ArrayList<TreeNode>();
+ rootNodes = new ArrayList<TreeNode>();
if(inputElement instanceof Set){
for (Object o: (Set)inputElement) {
if(o instanceof UUID){
UUID uuid = (UUID)o;
SpecimenOrObservationBase<?> rootElement = CdmStore.getService(IOccurrenceService.class).load(uuid);
if(rootElement!=null){
- rootElements.add(new TreeNode(rootElement));
+ rootNodes.add(new TreeNode(rootElement));
}
}
}
}
- return rootElements.toArray();
+ return rootNodes.toArray();
}
@Override
public static final String ID = "eu.etaxonomy.taxeditor.view.derivateSearch.DerivateSearchView";
private DerivateSearchCompositeController derivateSearchCompositeController;
private ConversationHolder conversationHolder;
- private final ICdmEntitySession cdmEntitySession;
+ private ICdmEntitySession cdmEntitySession;
/**
* Constructs a new DerivateSearchView and registers it to listen to context changes
*/
public DerivateSearchView() {
CdmStore.getContextManager().addContextListener(this);
- cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
}
/* (non-Javadoc)
*/
@Override
public void createPartControl(Composite parent) {
+
derivateSearchCompositeController = new DerivateSearchCompositeController(parent, this);
getSite().setSelectionProvider(derivateSearchCompositeController.getResultViewer());
derivateSearchCompositeController.setEnabled(CdmStore.isActive());
if(getConversationHolder()!=null && !getConversationHolder().isClosed() && !getConversationHolder().isBound()){
getConversationHolder().bind();
}
- cdmEntitySession.bind();
+ if(getCdmEntitySession() != null) {
+ getCdmEntitySession().bind();
+ }
}
/* (non-Javadoc)
@Override
public void contextRefresh(IProgressMonitor monitor) {
initConversation();
+ initSession();
+ }
+
+ private void initSession() {
+ if(CdmStore.isActive() && cdmEntitySession == null) {
+ cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
+ }
}
private void initConversation(){
*/
@Override
public ICdmEntitySession getCdmEntitySession() {
+ initSession();
return cdmEntitySession;
}