import eu.etaxonomy.cdm.common.monitor.NullProgressMonitor;
import eu.etaxonomy.taxeditor.remoting.cache.CdmRemoteCacheManager;
import eu.etaxonomy.taxeditor.remoting.source.ICdmRemoteSource;
+import eu.etaxonomy.taxeditor.service.ICachedCommonService;
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionManager;
/**
public ITestService getTestService(){
return (ITestService) getBean("testService");
}
+
+ public ICachedCommonService getCachedCommonService(){
+ return (ICachedCommonService) getBean("cachedCommonService");
+ }
}
import eu.etaxonomy.cdm.api.service.ICommonService;
import eu.etaxonomy.cdm.api.service.IService;
import eu.etaxonomy.cdm.api.service.ITestService;
+import eu.etaxonomy.taxeditor.service.ICachedCommonService;
/**
* @author cmathew
}
+ public static ICachedCommonService getCachedCommonService() {
+ ICdmApplicationConfiguration configuration = getCurrentAppConfig();
+
+ return ((CdmApplicationRemoteController)configuration).getCachedCommonService();
+
+ }
+
}
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
+import java.util.UUID;
import org.hibernate.collection.internal.PersistentBag;
import org.hibernate.collection.internal.PersistentList;
import org.hibernate.proxy.LazyInitializer;
import org.springframework.util.ReflectionUtils;
+import eu.etaxonomy.cdm.api.application.CdmApplicationState;
+import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.common.PersistentMultiLanguageText;
import eu.etaxonomy.taxeditor.remoting.CdmRemotingException;
return false;
}
+ public static Object remoteLoadPersistentCollectionIfProxy(Object o, UUID ownerUuid, String fieldName) throws ClassNotFoundException {
+ if(o != null && o instanceof HibernateProxy) {
+ LazyInitializer hli = ((HibernateProxy)o).getHibernateLazyInitializer();
+ if(hli.isUninitialized()) {
+ return CdmApplicationState.getCachedCommonService().find((Class<CdmBase>)Class.forName(hli.getEntityName()),
+ ((Integer)hli.getIdentifier()).intValue());
+ }
+ }
+
+ if(o != null && o instanceof PersistentCollection) {
+ PersistentCollection pc = ((PersistentCollection)o);
+ if(!pc.wasInitialized()) {
+ return CdmApplicationState.getCachedCommonService().initializeCollection(ownerUuid, fieldName);
+ }
+ }
+
+ return o;
+ }
+
+
+
+
public static void setRoleValueInOwner(Object owner, String role, Object value) {
if(role == null || role.isEmpty()) {
throw new CdmRemotingException("Role cannot be null or an empty string");
*/
@Override
public CdmBase find(Class<? extends CdmBase> clazz, int id) {
- if(cacheEnabled) {
- CdmBase cdmEntity = CdmBase.deproxy(commonService.find(clazz, id, getPropertyPaths(clazz)),clazz);
+// if(cacheEnabled) {
+ CdmBase cdmEntity = commonService.find(clazz, id, getPropertyPaths(clazz));
if(cdmEntity == null) {
throw new NullPointerException("CDM Entity of type " + clazz.getName() + " with id " + id + " is null.");
}
- return cdmEntitySessionManager.load(cdmEntity, false);
- } else {
- return CdmBase.deproxy(commonService.find(clazz, id),clazz);
- }
+ return cdmEntity;
+ //return cdmEntitySessionManager.load(cdmEntity, false);
+// } else {
+// return CdmBase.deproxy(commonService.find(clazz, id),clazz);
+// }
}
private final String name;
private final UUID keyUuid;
- private final PolytomousKey key;
+ private PolytomousKey key;
protected PolytomousKeyEditorInput(ConversationHolder conversation,
*/
@Override
public void merge() {
- CdmStore.getService(IPolytomousKeyService.class).merge(key);
+ key = CdmStore.getService(IPolytomousKeyService.class).merge(key);
}
}
// $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.
*/
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;
-import eu.etaxonomy.cdm.model.description.PolytomousKey;
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
/**
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface
* .viewers.Viewer, java.lang.Object, java.lang.Object)
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java
* .lang.Object)
*/
@Override
public Object[] getElements(Object inputElement) {
- if (inputElement instanceof PolytomousKey) {
+ if (inputElement instanceof PolytomousKeyEditorInput) {
List<PolytomousKeyNode> result = new ArrayList<PolytomousKeyNode>();
- PolytomousKeyNode root = ((PolytomousKey) inputElement).getRoot();
+ PolytomousKeyNode root = ((PolytomousKeyEditorInput) inputElement).getKey().getRoot();
getChildrenBreadthFirst(result, root);
return result.toArray();
setPartName(key.getTitleCache());
- viewer.setInput(key);
+ viewer.setInput(getEditorInput());
}
public int getTableItemCount() {
if (element instanceof PolytomousKeyNode) {
List<PolytomousKeyNode> children = ((PolytomousKeyNode) element)
.getParent().getChildren();
+ viewer.update(((PolytomousKeyNode) element)
+ .getParent(), null);
for (PolytomousKeyNode child : children) {
viewer.update(child, null);
}
}
+
}
/* (non-Javadoc)
/**
- *
+ *
*/
package eu.etaxonomy.taxeditor.editor.key.polytomous.operation;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import eu.etaxonomy.cdm.api.application.CdmApplicationState;
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
PolytomousKeyNode parentNode;
private PolytomousKeyNode childNode;
-
+
public CreateNodeOperation(String label,
IUndoContext undoContext, PolytomousKeyNode parentNode, IPostOperationEnabled postOperationEnabled) {
super(label, undoContext, postOperationEnabled);
throws ExecutionException {
childNode = PolytomousKeyNode.NewInstance();
-
- parentNode.addChild(childNode);
+ parentNode.addChild(childNode);
+ childNode = CdmApplicationState.getCurrentAppConfig().getPolytomousKeyNodeService().merge(childNode);
return postExecute(childNode);
}