Revision d774802a
Added by Andreas Müller almost 8 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/reference/Reference.java | ||
---|---|---|
568 | 568 |
} else{ |
569 | 569 |
this.type = type; |
570 | 570 |
} |
571 |
this.setCacheStrategy(type.getCacheStrategy()); |
|
572 | 571 |
} |
573 | 572 |
@Override |
574 | 573 |
public ReferenceType getType() { |
... | ... | |
719 | 718 |
// TODO implement |
720 | 719 |
@Transient |
721 | 720 |
public String getCitation(){ |
722 |
rectifyCacheStrategy(); |
|
723 | 721 |
if (getCacheStrategy() == null){ |
724 | 722 |
logger.warn("No CacheStrategy defined for "+ this.getClass() + ": " + this.getUuid()); |
725 | 723 |
return null; |
... | ... | |
731 | 729 |
|
732 | 730 |
@Override |
733 | 731 |
public String generateTitle() { |
734 |
rectifyCacheStrategy(); |
|
735 | 732 |
return super.generateTitle(); |
736 | 733 |
} |
737 | 734 |
|
738 | 735 |
public String generateAbbrevTitle() { |
739 |
rectifyCacheStrategy(); //TODO needed, is called by getCacheStrategy already |
|
740 | 736 |
return getCacheStrategy().getFullAbbrevTitleString(this); |
741 | 737 |
} |
742 | 738 |
|
... | ... | |
836 | 832 |
@Override |
837 | 833 |
@Transient |
838 | 834 |
public String getNomenclaturalCitation(String microReference) { |
839 |
rectifyCacheStrategy(); |
|
840 | 835 |
String typeName = this.getType()== null ? "(no type defined)" : this.getType().getMessage(); |
841 | 836 |
if (getCacheStrategy() == null){ |
842 | 837 |
logger.warn("No CacheStrategy defined for "+ typeName + ": " + this.getUuid()); |
... | ... | |
1019 | 1014 |
|
1020 | 1015 |
@Override |
1021 | 1016 |
public IReferenceCacheStrategy getCacheStrategy() { |
1022 |
rectifyCacheStrategy(); |
|
1023 | 1017 |
return this.cacheStrategy; |
1024 | 1018 |
} |
1025 | 1019 |
|
1026 |
/** |
|
1027 |
* The type property of this class is mapped on the field level to the data base column, so |
|
1028 |
* Hibernate will consequently use the {@link org.hibernate.property.DirectPropertyAccessor} |
|
1029 |
* to set the property. This PropertyAccessor directly sets the field instead of using the according setter so |
|
1030 |
* the CacheStrategy is not correctly set after the initialization of the bean. Thus we need to |
|
1031 |
* validate the CacheStrategy before it is to be used. |
|
1032 |
*/ |
|
1033 |
private void rectifyCacheStrategy() { |
|
1034 |
if(!cacheStrategyRectified ){ |
|
1035 |
setType(getType()); |
|
1036 |
cacheStrategyRectified = true; |
|
1037 |
} |
|
1020 |
@Override |
|
1021 |
public void setCacheStrategy(IReferenceCacheStrategy referenceCacheStrategy) { |
|
1022 |
this.cacheStrategy = referenceCacheStrategy; |
|
1038 | 1023 |
} |
1039 | 1024 |
|
1040 | 1025 |
|
1041 |
@Override |
|
1042 |
public void setCacheStrategy(IReferenceCacheStrategy iReferenceBaseCacheStrategy) { |
|
1043 |
this.cacheStrategy = iReferenceBaseCacheStrategy; |
|
1044 |
|
|
1045 |
} |
|
1046 |
|
|
1047 |
|
|
1048 |
|
|
1049 |
|
|
1050 |
// @Override |
|
1051 |
// protected void initListener(){ |
|
1052 |
// PropertyChangeListener listener = new PropertyChangeListener() { |
|
1053 |
// @Override |
|
1054 |
// public void propertyChange(PropertyChangeEvent e) { |
|
1055 |
// boolean protectedByLowerCache = false; |
|
1056 |
// //authorship cache |
|
1057 |
// if (fieldHasCacheUpdateProperty(e.getPropertyName(), "authorshipCache")){ |
|
1058 |
// if (protectedAuthorshipCache){ |
|
1059 |
// protectedByLowerCache = true; |
|
1060 |
// }else{ |
|
1061 |
// authorshipCache = null; |
|
1062 |
// } |
|
1063 |
// } |
|
1064 |
// |
|
1065 |
// //title cache |
|
1066 |
// if (! fieldHasNoUpdateProperty(e.getPropertyName(), "titleCache")){ |
|
1067 |
// if (isProtectedTitleCache()|| protectedByLowerCache == true ){ |
|
1068 |
// protectedByLowerCache = true; |
|
1069 |
// }else{ |
|
1070 |
// titleCache = null; |
|
1071 |
// } |
|
1072 |
// } |
|
1073 |
// //full title cache |
|
1074 |
// if (! fieldHasNoUpdateProperty(e.getPropertyName(), "fullTitleCache")){ |
|
1075 |
// if (isProtectedFullTitleCache()|| protectedByLowerCache == true ){ |
|
1076 |
// protectedByLowerCache = true; |
|
1077 |
// }else{ |
|
1078 |
// fullTitleCache = null; |
|
1079 |
// } |
|
1080 |
// } |
|
1081 |
// } |
|
1082 |
// }; |
|
1083 |
// addPropertyChangeListener(listener); //didn't use this.addXXX to make lsid.AssemblerTest run in cdmlib-remote |
|
1084 |
// } |
|
1085 |
|
|
1086 | 1026 |
|
1087 | 1027 |
//*********************** CLONE ********************************************************/ |
1088 | 1028 |
|
Also available in: Unified diff
Further clean up reference cache strategies #5833