Project

General

Profile

Download (2.26 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10

    
11
package eu.etaxonomy.taxeditor.newWizard;
12

    
13
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
14
import eu.etaxonomy.cdm.api.application.CdmChangeEvent;
15
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
16
import eu.etaxonomy.cdm.api.service.IClassificationService;
17
import eu.etaxonomy.cdm.model.taxon.Classification;
18
import eu.etaxonomy.taxeditor.store.CdmStore;
19
import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationWizardPage;
20

    
21
/**
22
 * <p>ClassificationWizard class.</p>
23
 *
24
 * @author n.hoffmann
25
 * @created 23.06.2009
26
 * @version 1.0
27
 */
28

    
29
public class NewClassificationWizard extends AbstractNewEntityWizard<Classification> {
30

    
31
	private ClassificationWizardPage classificationWizardPage;
32

    
33
	/* (non-Javadoc)
34
	 * @see eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard#setEntity(java.lang.Object)
35
	 */
36
	@Override
37
	public void setEntity(Classification entity) {
38
		setWindowTitle(String.format("Edit %s", getEntityName()));
39
		entity = CdmStore.getService(IClassificationService.class).load(entity.getUuid());
40
		super.setEntity(entity);
41
	}
42

    
43
	@Override
44
	public void addPages() {
45
		classificationWizardPage = new ClassificationWizardPage(formFactory, getConversationHolder(), getEntity());
46
		addPage(classificationWizardPage);
47
	}
48

    
49
	@Override
50
	protected void saveEntity() {
51
		//CdmStore.getService(IClassificationService.class).saveOrUpdate(getEntity());
52
	    Classification classification = getEntity();
53
	    if(CdmStore.getCurrentSessionManager().isRemoting()) {
54
	        CdmStore.getService(IClassificationService.class).merge(getEntity(), true);
55
	        CdmApplicationState.getCurrentDataChangeService()
56
	        .fireChangeEvent(new CdmChangeEvent(Action.Create, classification, NewTaxonNodeWizard.class), true);
57
	    } else {
58
	        CdmStore.getService(IClassificationService.class).save(getEntity());
59
	    }
60

    
61
	}
62

    
63
	@Override
64
	protected Classification createNewEntity() {
65
		return Classification.NewInstance(null);
66
	}
67

    
68
	@Override
69
	protected String getEntityName() {
70
		return "Classification";
71
	}
72
}
(6-6/22)