Fix NPE when connecting to local cdm server with dev settings
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / editor / CdmEntitySessionInput.java
1 /**
2 * Copyright (C) 2015 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 package eu.etaxonomy.taxeditor.editor;
10
11 import java.util.List;
12 import java.util.Map;
13
14 import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
15 import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
16 import eu.etaxonomy.taxeditor.store.CdmStore;
17
18 /**
19 * @author cmathew
20 * @date 5 Feb 2015
21 *
22 */
23 public abstract class CdmEntitySessionInput implements ICdmEntitySessionEnabled {
24
25 private ICdmEntitySession cdmEntitySession;
26
27 public CdmEntitySessionInput(boolean init) {
28 if(init) {
29 initSession();
30 }
31 }
32
33 protected void initSession() {
34 cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
35 }
36
37 @Override
38 public ICdmEntitySession getCdmEntitySession() {
39 return cdmEntitySession;
40 }
41
42 public void bind() {
43 if(cdmEntitySession!=null){
44 cdmEntitySession.bind();
45 }
46 else {
47 initSession();
48 }
49 }
50
51 public void dispose() {
52 if (cdmEntitySession != null){
53 cdmEntitySession.dispose();
54 }
55 cdmEntitySession = null;
56
57 }
58
59 public abstract void merge();
60
61
62 /* (non-Javadoc)
63 * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getPropertyPathsMap()
64 */
65 @Override
66 public Map<Object, List<String>> getPropertyPathsMap() {
67 // TODO Auto-generated method stub
68 return null;
69 }
70
71 }