Project

General

Profile

« Previous | Next » 

Revision a0af0095

Added by Patrick Plitzner over 8 years ago

Move getService to CdmStore

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java
28 28
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
29 29
import eu.etaxonomy.cdm.api.cache.CdmServiceCacher;
30 30
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
31
import eu.etaxonomy.cdm.api.service.IAgentService;
32
import eu.etaxonomy.cdm.api.service.ICollectionService;
31 33
import eu.etaxonomy.cdm.api.service.ICommonService;
34
import eu.etaxonomy.cdm.api.service.INameService;
35
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
36
import eu.etaxonomy.cdm.api.service.IReferenceService;
32 37
import eu.etaxonomy.cdm.api.service.IService;
38
import eu.etaxonomy.cdm.api.service.IUserService;
39
import eu.etaxonomy.cdm.api.service.molecular.IAmplificationService;
40
import eu.etaxonomy.cdm.api.service.molecular.IPrimerService;
33 41
import eu.etaxonomy.cdm.config.ICdmSource;
34 42
import eu.etaxonomy.cdm.database.DbSchemaValidation;
43
import eu.etaxonomy.cdm.model.agent.AgentBase;
35 44
import eu.etaxonomy.cdm.model.common.CdmBase;
36 45
import eu.etaxonomy.cdm.model.common.Language;
46
import eu.etaxonomy.cdm.model.common.User;
47
import eu.etaxonomy.cdm.model.molecular.Amplification;
48
import eu.etaxonomy.cdm.model.molecular.Primer;
49
import eu.etaxonomy.cdm.model.name.NonViralName;
50
import eu.etaxonomy.cdm.model.occurrence.Collection;
51
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
52
import eu.etaxonomy.cdm.model.reference.Reference;
37 53
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
38 54
import eu.etaxonomy.cdm.persistence.hibernate.permission.ICdmPermissionEvaluator;
39 55
import eu.etaxonomy.cdm.persistence.hibernate.permission.Role;
......
598 614
    }
599 615

  
600 616

  
617
    public static <T extends CdmBase> IService<T> getService(T cdmBase){
618
        IService<T> service = null;
619
        if(cdmBase!=null){
620
            //get corresponding service
621
            if(cdmBase.isInstanceOf(Reference.class)){
622
                service = (IService<T>) getService(IReferenceService.class);
623
            }
624
            else if (cdmBase.isInstanceOf(AgentBase.class)){
625
                service = (IService<T>) getService(IAgentService.class);
626
            }
627
            else if (cdmBase instanceof NonViralName) {
628
                service = (IService<T>) getService(INameService.class);
629
            }
630
            else if (cdmBase instanceof SpecimenOrObservationBase) {
631
                service = (IService<T>) getService(IOccurrenceService.class);
632
            }
633
            else if (cdmBase instanceof Collection) {
634
                service = (IService<T>) getService(ICollectionService.class);
635
            }
636
            else if (cdmBase instanceof User) {
637
                service = (IService<T>) getService(IUserService.class);
638
            }
639
            else if (cdmBase instanceof Primer) {
640
                service = (IService<T>) getService(IPrimerService.class);
641
            }
642
            else if (cdmBase instanceof Amplification) {
643
                service = (IService<T>) getService(IAmplificationService.class);
644
            }
645
        }
646
        return service;
647
    }
648

  
601 649
    public static void setManagedServer(CDMServer server) {
602 650
        managedServer = server;
603 651
    }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EditFromSelectionWizard.java
89 89
		CdmFormFactory formFactory = selectionElement.getFormFactory();
90 90
		CdmBase entity = (CdmBase) HibernateProxyHelper
91 91
				.deproxy(selectionElement.getEntity());
92
		IService<CdmBase> service = EntitySelectionElement.getService(entity);
92
		IService<CdmBase> service = CdmStore.getService(entity);
93 93
		rootElement = service.load(entity.getUuid());
94 94
		if (rootElement.isInstanceOf(Reference.class)) {
95 95
			addPage(new ReferenceWizardPage(formFactory,
......
165 165
	/** {@inheritDoc} */
166 166
	@Override
167 167
	public boolean performFinish() {
168
	    IService<CdmBase> service = EntitySelectionElement.getService(rootElement);
168
	    IService<CdmBase> service = CdmStore.getService(rootElement);
169 169
	    service.merge(rootElement, true);
170 170
	    previousCdmEntitySession.load(rootElement, true);
171 171
		return true;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EntitySelectionElement.java
23 23

  
24 24
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
25 25
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
26
import eu.etaxonomy.cdm.api.service.IAgentService;
27
import eu.etaxonomy.cdm.api.service.ICollectionService;
28
import eu.etaxonomy.cdm.api.service.INameService;
29
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
30
import eu.etaxonomy.cdm.api.service.IReferenceService;
31
import eu.etaxonomy.cdm.api.service.IService;
32
import eu.etaxonomy.cdm.api.service.IUserService;
33
import eu.etaxonomy.cdm.api.service.molecular.IAmplificationService;
34
import eu.etaxonomy.cdm.api.service.molecular.IPrimerService;
35 26
import eu.etaxonomy.cdm.common.CdmUtils;
36
import eu.etaxonomy.cdm.model.agent.AgentBase;
37 27
import eu.etaxonomy.cdm.model.common.CdmBase;
38 28
import eu.etaxonomy.cdm.model.common.Group;
39 29
import eu.etaxonomy.cdm.model.common.IIdentifiableEntity;
40 30
import eu.etaxonomy.cdm.model.common.User;
41 31
import eu.etaxonomy.cdm.model.molecular.Amplification;
42 32
import eu.etaxonomy.cdm.model.molecular.Primer;
43
import eu.etaxonomy.cdm.model.name.NonViralName;
44
import eu.etaxonomy.cdm.model.occurrence.Collection;
45
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
46
import eu.etaxonomy.cdm.model.reference.Reference;
47 33
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
48 34
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
49 35
import eu.etaxonomy.taxeditor.model.ImageResources;
......
236 222
		setSelectionInternal(selection);
237 223
	}
238 224

  
239
	public static <T extends CdmBase> IService<T> getService(T cdmBase){
240
	    IService<T> service = null;
241
	    if(cdmBase!=null){
242
            //get corresponding service
243
            if(cdmBase.isInstanceOf(Reference.class)){
244
                service = (IService<T>) CdmStore.getService(IReferenceService.class);
245
            }
246
            else if (cdmBase.isInstanceOf(AgentBase.class)){
247
                service = (IService<T>) CdmStore.getService(IAgentService.class);
248
            }
249
            else if (cdmBase instanceof NonViralName) {
250
                service = (IService<T>) CdmStore.getService(INameService.class);
251
            }
252
            else if (cdmBase instanceof SpecimenOrObservationBase) {
253
                service = (IService<T>) CdmStore.getService(IOccurrenceService.class);
254
            }
255
            else if (cdmBase instanceof Collection) {
256
                service = (IService<T>) CdmStore.getService(ICollectionService.class);
257
            }
258
            else if (cdmBase instanceof User) {
259
                service = (IService<T>) CdmStore.getService(IUserService.class);
260
            }
261
            else if (cdmBase instanceof Primer) {
262
                service = (IService<T>) CdmStore.getService(IPrimerService.class);
263
            }
264
            else if (cdmBase instanceof Amplification) {
265
                service = (IService<T>) CdmStore.getService(IAmplificationService.class);
266
            }
267
	    }
268
	    return service;
269
	}
270

  
271 225
	/**
272 226
	 * Return the selected object
273 227
	 *

Also available in: Unified diff