Merge branch 'release/4.7.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / newWizard / NewGrantedAuthorityWizard.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9
10 package eu.etaxonomy.taxeditor.newWizard;
11
12 import eu.etaxonomy.cdm.api.service.IGrantedAuthorityService;
13 import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
14 import eu.etaxonomy.taxeditor.l10n.Messages;
15 import eu.etaxonomy.taxeditor.model.MessagingUtils;
16 import eu.etaxonomy.taxeditor.store.CdmStore;
17 import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailWizardPage;
18
19 /**
20 * @author a.kohlbecker
21 * @created Sept 13 2012
22 */
23 public class NewGrantedAuthorityWizard extends AbstractNewEntityWizard<GrantedAuthorityImpl> {
24
25 private GrantedAuthorityDetailWizardPage authorityPage;
26
27 /* (non-Javadoc)
28 * @see org.eclipse.jface.wizard.Wizard#addPages()
29 */
30 @Override
31 public void addPages() {
32 authorityPage = new GrantedAuthorityDetailWizardPage(formFactory, getConversationHolder(), getEntity());
33 super.addPage(authorityPage);
34 }
35
36
37 /* (non-Javadoc)
38 * @see eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard#saveEntity()
39 */
40 @Override
41 protected void saveEntity() {
42 try{
43 CdmStore.getService(IGrantedAuthorityService.class).merge(getEntity(), true);
44 }catch (Exception e){
45 MessagingUtils.info(Messages.NewGrantedAuthority_AlreadyInDb);
46 }
47
48 }
49
50 /* (non-Javadoc)
51 * @see eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard#createNewEntity()
52 */
53 @Override
54 protected GrantedAuthorityImpl createNewEntity() {
55 return GrantedAuthorityImpl.NewInstance("");
56 }
57
58 /* (non-Javadoc)
59 * @see eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard#getEntityName()
60 */
61 @Override
62 protected String getEntityName() {
63 return "GrantedAuthority";
64 }
65 }