performed javacscript:fix and worked on documentation
[taxeditor.git] / taxeditor-bulkeditor / src / main / java / eu / etaxonomy / taxeditor / bulkeditor / input / ReferenceEditorInput.java
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 package eu.etaxonomy.taxeditor.bulkeditor.input;
11
12 import java.util.Arrays;
13 import java.util.List;
14 import java.util.UUID;
15
16 import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
17 import eu.etaxonomy.cdm.model.common.MarkerType;
18 import eu.etaxonomy.cdm.model.reference.ReferenceBase;
19 import eu.etaxonomy.taxeditor.bulkeditor.command.BulkEditorInputTypeValues.BulkEditorInputType;
20 import eu.etaxonomy.taxeditor.store.CdmStore;
21
22
23 /**
24 * <p>ReferenceEditorInput class.</p>
25 *
26 * @author p.ciardelli
27 * @created 25.06.2009
28 * @version 1.0
29 */
30 public class ReferenceEditorInput extends AbstractBulkEditorInput<ReferenceBase> {
31
32 /**
33 *
34 */
35 private static final long serialVersionUID = 3806243517765126749L;
36
37 /** Constant <code>ID="bulkeditor.input.reference"</code> */
38 public static final String ID = "bulkeditor.input.reference";
39
40 private static ReferenceEditorInput instance;
41
42 /**
43 * <p>Constructor for ReferenceEditorInput.</p>
44 */
45 public ReferenceEditorInput() {
46 super(new Object());
47 }
48
49 /**
50 * <p>getID</p>
51 *
52 * @return the iD
53 */
54 public static String getID() {
55 return ID;
56 }
57
58 /* (non-Javadoc)
59 * @see org.eclipse.ui.IEditorInput#getName()
60 */
61 /**
62 * <p>getName</p>
63 *
64 * @return a {@link java.lang.String} object.
65 */
66 public String getName() {
67 return BulkEditorInputType.REFERENCE.label;
68 }
69
70 /* (non-Javadoc)
71 * @see org.eclipse.ui.IEditorInput#getToolTipText()
72 */
73 /**
74 * <p>getToolTipText</p>
75 *
76 * @return a {@link java.lang.String} object.
77 */
78 public String getToolTipText() {
79 return getName();
80 }
81
82 /**
83 * <p>Getter for the field <code>instance</code>.</p>
84 *
85 * @return a {@link eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput} object.
86 */
87 public static AbstractBulkEditorInput getInstance() {
88 if (instance == null) {
89 instance = new ReferenceEditorInput();
90 }
91 return instance;
92 }
93
94 /* (non-Javadoc)
95 * @see eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInput#isMergingEnabled()
96 */
97 /** {@inheritDoc} */
98 @Override
99 public boolean isMergingEnabled() {
100 return true;
101 }
102
103 /* (non-Javadoc)
104 * @see eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInput#isMarkerTypeEditingEnabled(eu.etaxonomy.cdm.model.common.MarkerType)
105 */
106 /** {@inheritDoc} */
107 @Override
108 public boolean isMarkerTypeEditingEnabled(MarkerType markerType) {
109 if (MarkerType.PUBLISH().equals(markerType)) {
110 return true;
111 }
112 return super.isMarkerTypeEditingEnabled(markerType);
113 }
114
115 // Entity persistence
116
117 /** {@inheritDoc} */
118 @Override
119 public List listEntities(IIdentifiableEntityServiceConfigurator configurator) {
120 return CdmStore.findReferences(configurator);
121 }
122
123 /** {@inheritDoc} */
124 @Override
125 public ReferenceBase loadEntity(UUID entityUuid) {
126 List<String> propertyPaths = Arrays.asList(new String[]{"*", "inReference.*", "authorTeam.*"});
127 return CdmStore.getReferenceService().load(entityUuid, propertyPaths);
128 }
129
130 /** {@inheritDoc} */
131 public boolean delete(Object entity) {
132 return CdmStore.getReferenceService().delete((ReferenceBase) entity) != null;
133 }
134
135 /** {@inheritDoc} */
136 public boolean save(Object entity) {
137 return CdmStore.getReferenceService().saveOrUpdate((ReferenceBase) entity) != null;
138 }
139 }