Project

General

Profile

« Previous | Next » 

Revision bd4c6676

Added by Andreas Müller almost 3 years ago

ref #9678 implement cache strategies for field unit and derived unti within cdmlib model

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/FieldUnit.java
37 37

  
38 38
import eu.etaxonomy.cdm.model.agent.Person;
39 39
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
40
import eu.etaxonomy.cdm.strategy.cache.common.IdentifiableEntityDefaultCacheStrategy;
40
import eu.etaxonomy.cdm.strategy.cache.occurrence.FieldUnitDefaultCacheStrategy;
41 41

  
42 42
/**
43 43
 *
......
118 118

  
119 119
//****************************** CACHE STRATEGY **************************************/
120 120

  
121
    private static final String facadeStrategyClassName =
122
            "eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeFieldUnitCacheStrategy";
123

  
124 121
    /**
125 122
     * Sets the default cache strategy
126 123
     */
127 124
    @Override
128 125
    protected void initDefaultCacheStrategy() {
129
        try {
130
            String facadeClassName = facadeStrategyClassName;
131
            Class<?> facadeClass = Class.forName(facadeClassName);
132
            try {
133
                this.cacheStrategy = (IIdentifiableEntityCacheStrategy)facadeClass.newInstance();
134
            } catch (InstantiationException | IllegalAccessException e) {
135
                throw new RuntimeException("Cache strategy for FieldUnit could not be instantiated", e);
136

  
137
            }
138
        } catch (ClassNotFoundException e) {
139
            this.cacheStrategy = new IdentifiableEntityDefaultCacheStrategy<FieldUnit>();
140
        }
126
        this.cacheStrategy = FieldUnitDefaultCacheStrategy.NewInstance();
141 127
    }
142 128

  
143

  
144

  
145

  
146 129
// ************************ GETTER / SETTER *******************************************
147 130

  
148
	public GatheringEvent getGatheringEvent() {
131
	@Override
132
    public String getTitleCache() {
133
	    //most changes in fieldUnits take place in gathering events, therefore we compute titleCache each time from scratch
134
        if (!this.protectedTitleCache){
135
            this.titleCache = null;
136
        }
137
        return super.getTitleCache();
138
    }
139

  
140
    public GatheringEvent getGatheringEvent() {
149 141
    	return gatheringEvent;
150 142
	}
151 143

  

Also available in: Unified diff