import eu.etaxonomy.cdm.model.common.LSID;
import eu.etaxonomy.cdm.model.common.MarkerType;
import eu.etaxonomy.cdm.model.media.Rights;
-import eu.etaxonomy.cdm.model.name.NonViralName;
+import eu.etaxonomy.cdm.model.name.INonViralName;
+import eu.etaxonomy.cdm.model.name.ITaxonName;
+import eu.etaxonomy.cdm.model.name.TaxonName;
import eu.etaxonomy.cdm.model.reference.Reference;
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
import eu.etaxonomy.cdm.persistence.dao.common.IIdentifiableDao;
if (entity.getTitleCache() != null){
//System.err.println(entity.getTitleCache());
}else{
- //System.err.println("no titleCache" + ((NonViralName)entity).getNameCache());
+ //System.err.println("no titleCache" + ((TaxonName)entity).getNameCache());
}
}
saveOrUpdate(entitiesToUpdate);
@SuppressWarnings("unchecked")
private void updateTitleCacheForSingleEntity(
IIdentifiableEntityCacheStrategy<T> cacheStrategy,
- List<T> entitiesToUpdate, T entity) {
+ List<T> entitiesToUpdate,
+ T entity) {
//assert (entity.isProtectedTitleCache() == false );
+ entity = CdmBase.deproxy(entity);
//exclude recursive inreferences
if (entity.isInstanceOf(Reference.class)){
- Reference ref = CdmBase.deproxy(entity, Reference.class);
+ Reference ref = (Reference)entity;
if (ref.getInReference() != null && ref.getInReference().equals(ref)){
return;
}
}
-
//old titleCache
entity.setProtectedTitleCache(true);
String oldNameCache = null;
String oldFullTitleCache = null;
String oldAbbrevTitleCache = null;
- if (entity instanceof NonViralName ){
-
- try{
- NonViralName<?> nvn = (NonViralName) entity;
- if (!nvn.isProtectedNameCache()){
- nvn.setProtectedNameCache(true);
- oldNameCache = nvn.getNameCache();
- nvn.setProtectedNameCache(false);
- }
- if (!nvn.isProtectedFullTitleCache()){
- nvn.setProtectedFullTitleCache(true);
- oldFullTitleCache = nvn.getFullTitleCache();
- nvn.setProtectedFullTitleCache(false);
- }
- }catch(ClassCastException e){
- System.out.println("entity: " + entity.getTitleCache());
- }
+ if (entity instanceof TaxonName ){
+ if (((TaxonName) entity).isNonViral()) {
+ try{
+ INonViralName nvn = (INonViralName) entity;
+ if (!nvn.isProtectedNameCache()){
+ nvn.setProtectedNameCache(true);
+ oldNameCache = nvn.getNameCache();
+ nvn.setProtectedNameCache(false);
+ }
+ if (!nvn.isProtectedFullTitleCache()){
+ nvn.setProtectedFullTitleCache(true);
+ oldFullTitleCache = nvn.getFullTitleCache();
+ nvn.setProtectedFullTitleCache(false);
+ }
+ }catch(ClassCastException e){
+ System.out.println("entity: " + entity.getTitleCache());
+ }
+ }
}else if (entity instanceof Reference){
Reference ref = (Reference) entity;
}
setOtherCachesNull(entity);
String newTitleCache= null;
- NonViralName<?> nvn = null;//TODO find better solution
+ INonViralName nvn = null; //TODO find better solution
try{
- if (entity instanceof NonViralName){
- nvn = (NonViralName) entity;
+ if (entity instanceof TaxonName){
+ nvn = (ITaxonName) entity;
newTitleCache = entityCacheStrategy.getTitleCache(nvn);
} else{
newTitleCache = entityCacheStrategy.getTitleCache(entity);
}
}catch (ClassCastException e){
- nvn = HibernateProxyHelper.deproxy(entity, NonViralName.class);
+ nvn = HibernateProxyHelper.deproxy(entity, TaxonName.class);
newTitleCache = entityCacheStrategy.getTitleCache(nvn);
- //System.out.println("titleCache: " +entity.getTitleCache());
}
- if ( oldTitleCache == null || oldTitleCache != null && ! oldTitleCache.equals(newTitleCache) ){
+ if ( oldTitleCache == null || ! oldTitleCache.equals(newTitleCache) ){
entity.setTitleCache(null, false);
String newCache = entity.getTitleCache();
logger.info("oldTitleCache should never be null");
}
if (nvn != null){
- //NonViralName<?> nvn = (NonViralName) entity;
nvn.getNameCache();
nvn.getFullTitleCache();
}
}
entitiesToUpdate.add(entity);
}else if (nvn != null){
- //NonViralName<?> nvn = (NonViralName) entity;
String newNameCache = nvn.getNameCache();
String newFullTitleCache = nvn.getFullTitleCache();
if ((oldNameCache == null && !nvn.isProtectedNameCache()) || (oldNameCache != null && !oldNameCache.equals(newNameCache))){
}
}
-
}
-
/**
* Needs override if not only the title cache should be set to null to
* generate the correct new title cache
return;
}
-
-
private class DeduplicateState{
String lastTitleCache;
Integer pageSize = 50;