Project

General

Profile

« Previous | Next » 

Revision 68df9072

Added by Andreas Müller about 9 years ago

merge trunk into taxeditor-validation3 trunk

View differences:

eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java
20 20
import org.eclipse.ui.IEditorInput;
21 21
import org.eclipse.ui.IPersistableElement;
22 22

  
23
import eu.etaxonomy.cdm.api.service.ICommonService;
24
import eu.etaxonomy.cdm.api.service.ITaxonService;
25 23
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
26 24
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
27 25
import eu.etaxonomy.cdm.model.common.ICdmBase;
28 26
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
29 27
import eu.etaxonomy.cdm.model.common.MarkerType;
30
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
31
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
32 28
import eu.etaxonomy.cdm.strategy.merge.IMergable;
33 29
import eu.etaxonomy.cdm.strategy.merge.MergeException;
34 30
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
......
51 47
 */
52 48
public abstract class AbstractBulkEditorInput<T extends ICdmBase> implements IEditorInput, IEntityPersistenceService<T> {
53 49

  
54
	/**
55
	 *
56
	 */
57
	private static final long serialVersionUID = 416414530232743735L;
58

  
59 50
	private UUID entityUuid;
60 51

  
61 52
	private List<T> model;
......
235 226
    public boolean merge(T entity, T mergeTarget) {
236 227
		if (entity instanceof IMergable) {
237 228
			try {
238
				CdmStore.getService(ICommonService.class).merge((IMergable)mergeTarget, (IMergable)entity, null);				
229
				CdmStore.getCommonService().merge((IMergable)mergeTarget, (IMergable)entity, null);				
239 230
			} catch (MergeException e) {
240 231
				MessagingUtils.errorDialog("Bulk Editor Merge Error",
241 232
						this,
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/referencingobjects/ReferencingObjectsView.java
186 186
        	
187 187
        	if (referencedObject != null){
188 188
        		referencedObjectTitleCache = ((IdentifiableEntity)referencedObject).getTitleCache();
189
        		setOfReferencingObjects = CdmStore.getService(ICommonService.class).getReferencingObjects(referencedObject);
189
        		setOfReferencingObjects = CdmStore.getCommonService().getReferencingObjects(referencedObject);
190 190
        	}
191 191
	        if (setOfReferencingObjects != null){
192 192
		       	List<CdmBase> referencingObjects = new ArrayList<CdmBase>(setOfReferencingObjects);	        	
eu.etaxonomy.taxeditor.cdmlib/META-INF/MANIFEST.MF
25 25
 eu.etaxonomy.cdm.api.service.statistics,
26 26
 eu.etaxonomy.cdm.api.service.util,
27 27
 eu.etaxonomy.cdm.api.utility,
28
 eu.etaxonomy.cdm.api.validation,
29
 eu.etaxonomy.cdm.api.validation.batch,
28 30
 eu.etaxonomy.cdm.aspectj,
29 31
 eu.etaxonomy.cdm.common,
30 32
 eu.etaxonomy.cdm.common.media,
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/localApplicationContext.xml
3 3
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 4
	xmlns:context="http://www.springframework.org/schema/context"
5 5
	xmlns:tx="http://www.springframework.org/schema/tx"
6
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
7
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
8
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
6
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
7
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
8
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
9 9
	
10 10
	
11 11
    <!-- Default application context and term initializer -->
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/remotingApplicationContext.xml
3 3
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 4
	xmlns:context="http://www.springframework.org/schema/context"
5 5
	xmlns:tx="http://www.springframework.org/schema/tx"
6
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
7
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
8
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
6
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
7
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
8
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
9 9
	
10 10
	
11 11
    <!--  <bean id="remoteTermInitializer" class="eu.etaxonomy.cdm.remote.service.RemoteTermInitializer"/>-->
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/remoting_persistence_security.xml
3 3
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
4 4
  xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
5 5
  xsi:schemaLocation="http://www.springframework.org/schema/beans
6
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
7
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
8
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
9
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
6
    http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
7
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
8
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
9
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
10 10
    ">
11 11

  
12 12

  
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/remoting_services_security.xml
3 3
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 4
  xmlns:context="http://www.springframework.org/schema/context"
5 5
  xmlns:security="http://www.springframework.org/schema/security"
6
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
7
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
8
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
6
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
7
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
8
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
9 9
    http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"
10 10
    >
11 11

  
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/validation/MarkerManager.java
1 1
package eu.etaxonomy.taxeditor.editor.validation;
2 2

  
3
import java.util.HashMap;
3
import java.util.ArrayList;
4 4
import java.util.List;
5 5
import java.util.Set;
6 6

  
......
13 13
import org.eclipse.core.runtime.CoreException;
14 14

  
15 15
import eu.etaxonomy.cdm.model.validation.EntityConstraintViolation;
16
import eu.etaxonomy.cdm.model.validation.EntityValidationResult;
16
import eu.etaxonomy.cdm.model.validation.EntityValidation;
17 17
import eu.etaxonomy.cdm.model.validation.Severity;
18 18

  
19 19
/**
20 20
 * A class responsible for refreshing problem markers coming from the CVI
21 21
 * (Cdmlib Validation Infrastructure).
22
 * 
22
 *
23 23
 * @author ayco_holleman
24
 * 
24
 *
25 25
 */
26

  
26 27
/*
27 28
 * See following for problems with icons in Problems view
28 29
 * http://stackoverflow.com
......
34 35
 * http
35 36
 * ://cubussapiens.hu/2010/11/markers-and-annotations-in-eclipse-for-error-feedback
36 37
 * /
37
 * 
38
 *
38 39
 * See here for difficulty of attaching markers to non-resources (files,
39 40
 * folders):
40 41
 * http://stackoverflow.com/questions/12493179/eclipse-virtual-resources
41 42
 */
42 43
public class MarkerManager {
43 44

  
44
	public static final String MARKER_TYPE_ID = "eu.etaxonomy.taxeditor.markers.validationerror";
45

  
46
	/**
47
	 * The primary key (id) of the EntityValidationResult record
48
	 */
49
	public static final String ATTRIB_DATABASE_ID = "databaseId";
50

  
51
	// The values of the following constants must correspond to the attributes
52
	// defined for the org.eclipse.core.resources.markers extension point in
53
	// plugin.xml
54

  
55
	/**
56
	 * A user-friendly description of the type of the entity
57
	 */
58
	public static final String ATTRIB_USER_FRIENDLY_TYPE_NAME = "userFriendlyTypeName";
59
	/**
60
	 * A user-friendly description of the entity
61
	 */
62
	public static final String ATTRIB_USER_FRIENDLY_DESCRIPTION = "userFriendlyDescription";
63
	/**
64
	 * The field whose value violated a constraint
65
	 */
66
	public static final String ATTRIB_USER_FRIENDLY_FIELD_NAME = "userFriendlyFieldName";
67
	/**
68
	 * The value violating a constraint
69
	 */
70
	public static final String ATTRIB_INVALID_VALUE = "invalidValue";
71
	/**
72
	 * The message from the {@link Validator} about what was wrong.
73
	 */
74
	public static final String ATTRIB_VALIDATOR_MESSAGE = "validatorMessage";
75
	/**
76
	 * The class of the {@link Validator} coding for the constraint
77
	 */
78
	public static final String ATTRIB_VALIDATOR_CLASS = "validatorClass";
79
	/**
80
	 * The class of the validated entity
81
	 */
82
	public static final String ATTRIB_ENTITY_CLASS = "entityClass";
83
	/**
84
	 * The id of the validated entity
85
	 */
86
	public static final String ATTRIB_ENTITY_ID = "entityId";
87

  
88
	private final IWorkspaceRoot root;
89
	private final IMarker[] markers;
90
	private final List<EntityValidationResult> results;
91
	private final HashMap<Integer, EntityValidationResult> resultMap;
92
	private final HashMap<Integer, IMarker> markerMap;
93

  
94

  
95
	MarkerManager(List<EntityValidationResult> results) throws CoreException
96
	{
97
		this.root = ResourcesPlugin.getWorkspace().getRoot();
98
		this.markers = root.findMarkers(MARKER_TYPE_ID, true, IResource.DEPTH_INFINITE);
99
		this.markerMap = new HashMap<Integer, IMarker>();
100
		for (IMarker marker : markers) {
101
			markerMap.put(getDatabaseId(marker), marker);
102
		}
103
		this.results = results;
104
		this.resultMap = new HashMap<Integer, EntityValidationResult>();
105
		for (EntityValidationResult result : results) {
106
			resultMap.put(result.getId(), result);
107
		}
108
	}
109

  
110

  
111
	/**
112
	 * Delete all markers that refer to errors that do not exist any longer
113
	 * (i.e. the corresponding database record has been deleted).
114
	 * 
115
	 * @return The number of deleted markers
116
	 * 
117
	 * @throws CoreException
118
	 */
119
	int deleteObsoleteMarkers() throws CoreException
120
	{
121
		int i = 0;
122
		IMarker[] markers = root.findMarkers(MARKER_TYPE_ID, true, IResource.DEPTH_INFINITE);
123
		for (IMarker marker : markers) {
124
			if (isObsoleteMarker(marker)) {
125
				++i;
126
				marker.delete();
127
			}
128
		}
129
		return i;
130
	}
131

  
132

  
133
	/**
134
	 * Create markers for new errors (i.e. no marker has been created for them
135
	 * yet).
136
	 * 
137
	 * @return The number of new markers
138
	 * 
139
	 * @throws CoreException
140
	 */
141
	int createMarkers() throws CoreException
142
	{
143
		int i = 0;
144
		IMarker[] markers = root.findMarkers(MARKER_TYPE_ID, true, IResource.DEPTH_INFINITE);
145
		for (EntityValidationResult result : results) {
146
			if (!isNewResult(result)) {
147
				continue;
148
			}
149
			Set<EntityConstraintViolation> problems = result.getEntityConstraintViolations();
150
			for (EntityConstraintViolation problem : problems) {
151
				if (markerExistsForProblem(problem, markers)) {
152
					continue;
153
				}
154
				IMarker marker = root.createMarker(MARKER_TYPE_ID);
155
				++i;
156
				if (problem.getSeverity() == Severity.ERROR) {
157
					marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
158
				}
159
				else if (problem.getSeverity() == Severity.WARNING) {
160
					marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
161
				}
162
				else {
163
					marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO);
164
				}
165
				marker.setAttribute(IMarker.MESSAGE, problem.getMessage());
166
				marker.setAttribute(ATTRIB_DATABASE_ID, result.getId());
167
				marker.setAttribute(ATTRIB_USER_FRIENDLY_TYPE_NAME, result.getUserFriendlyTypeName());
168
				marker.setAttribute(ATTRIB_USER_FRIENDLY_DESCRIPTION, result.getUserFriendlyDescription());
169
				marker.setAttribute(ATTRIB_USER_FRIENDLY_FIELD_NAME, problem.getUserFriendlyFieldName());
170
				marker.setAttribute(ATTRIB_VALIDATOR_MESSAGE, problem.getMessage());
171
				marker.setAttribute(ATTRIB_INVALID_VALUE, problem.getInvalidValue());
172
				marker.setAttribute(ATTRIB_VALIDATOR_CLASS, problem.getValidator());
173
				marker.setAttribute(ATTRIB_ENTITY_CLASS, result.getValidatedEntityClass());
174
				marker.setAttribute(ATTRIB_ENTITY_ID, result.getValidatedEntityId());
175
			}
176
		}
177
		return i;
178
	}
179

  
180

  
181
	/**
182
	 * Is there a problem marker that captures the specified
183
	 * {@link EntityConstraintViolation}? See
184
	 * {@link #markerCapturesProblem(IMarker, EntityConstraintViolation)}.
185
	 * 
186
	 * @param problem
187
	 * @param markers
188
	 * @return
189
	 * @throws CoreException
190
	 */
191
	private boolean markerExistsForProblem(EntityConstraintViolation problem, IMarker[] markers) throws CoreException
192
	{
193
		for (IMarker marker : markers) {
194
			if (markerCapturesProblem(marker, problem)) {
195
				return true;
196
			}
197
		}
198
		return false;
199
	}
200

  
201

  
202
	/**
203
	 * <p>
204
	 * This method determines whether the problem exposed by the specified
205
	 * marker is <b>de facto</b> equivalent to the specified
206
	 * {@code EntityConstraintViolation}. When the CVI validates an entity, it
207
	 * first deletes previous validation results for that entity and only then
208
	 * saves the new validation result. Thus you cannot rely on the database id
209
	 * of the {@code EntityConstraintViolation} to determine equivalence. Maybe
210
	 * later we can make the CVI more sophisticated in this respect. Or maybe
211
	 * see if solving it through the equals() method of
212
	 * {@code EntityValidationResult} and/or {@code EntityConstraintViolation}
213
	 * is possible. But for now this is the easiest solution.
214
	 * </p>
215
	 * <p>
216
	 * The reason we check for equivalence, is that we don't want to
217
	 * unnecessarily update the Problems view. If a marker is there, we don't
218
	 * want to replace it with an equivalent marker, because that might lead to
219
	 * strange click behaviour for end users (e.g. selected problems will
220
	 * disappear and re-appear unselected).
221
	 * </p>
222
	 * 
223
	 * @param marker
224
	 * @param problem
225
	 * @return
226
	 * @throws CoreException
227
	 */
228
	private static boolean markerCapturesProblem(IMarker marker, EntityConstraintViolation problem) throws CoreException
229
	{
230
		EntityValidationResult result = problem.getEntityValidationResult();
231
		if (!marker.getAttribute(ATTRIB_ENTITY_CLASS).equals(result.getValidatedEntityClass())) {
232
			return false;
233
		}
234
		if (!marker.getAttribute(ATTRIB_ENTITY_ID).equals(result.getValidatedEntityId())) {
235
			return false;
236
		}
237
		if (!marker.getAttribute(ATTRIB_USER_FRIENDLY_FIELD_NAME).equals(problem.getPropertyPath())) {
238
			return false;
239
		}
240
		if (!marker.getAttribute(ATTRIB_INVALID_VALUE).equals(problem.getInvalidValue())) {
241
			return false;
242
		}
243
		if (!marker.getAttribute(ATTRIB_VALIDATOR_CLASS).equals(problem.getValidator())) {
244
			return false;
245
		}
246
		return true;
247
	}
248

  
249

  
250
	/**
251
	 * Is this a marker without a corresponding database record (
252
	 * {@link EntityValidationResult})?
253
	 * 
254
	 * @param marker
255
	 * @return
256
	 * @throws CoreException
257
	 */
258
	private boolean isObsoleteMarker(IMarker marker) throws CoreException
259
	{
260
		return resultMap.get(getDatabaseId(marker)) == null;
261
	}
262

  
263

  
264
	/**
265
	 * Is this an {@link EntityValidationResult} for which no marker has been
266
	 * created yet?
267
	 * 
268
	 * @param result
269
	 * @return
270
	 */
271
	private boolean isNewResult(EntityValidationResult result)
272
	{
273
		return markerMap.get(result.getId()) == null;
274
	}
275

  
276

  
277
	/**
278
	 * Get the id of the {@link EntityValidationResult} that was stored as one
279
	 * of the marker's attributes.
280
	 * 
281
	 * @param marker
282
	 * @return
283
	 * @throws CoreException
284
	 */
285
	private static Integer getDatabaseId(IMarker marker) throws CoreException
286
	{
287
		return (Integer) marker.getAttribute(ATTRIB_DATABASE_ID);
288
	}
45
    public static final String MARKER_TYPE_ID = "eu.etaxonomy.taxeditor.markers.validationerror";
46

  
47
    /**
48
     * The primary key (id) of the EntityConstraintViolation record
49
     */
50
    public static final String ATTRIB_DATABASE_ID = "databaseId";
51

  
52
    // The values of the following constants must correspond to the attributes
53
    // defined for the org.eclipse.core.resources.markers extension point in
54
    // plugin.xml
55

  
56
    /**
57
     * A user-friendly description of the type of the entity
58
     */
59
    public static final String ATTRIB_USER_FRIENDLY_TYPE_NAME = "userFriendlyTypeName";
60
    /**
61
     * A user-friendly description of the entity
62
     */
63
    public static final String ATTRIB_USER_FRIENDLY_DESCRIPTION = "userFriendlyDescription";
64
    /**
65
     * The field whose value violated a constraint
66
     */
67
    public static final String ATTRIB_USER_FRIENDLY_FIELD_NAME = "userFriendlyFieldName";
68
    /**
69
     * The value violating a constraint
70
     */
71
    public static final String ATTRIB_INVALID_VALUE = "invalidValue";
72
    /**
73
     * The message from the {@link Validator} about what was wrong.
74
     */
75
    public static final String ATTRIB_VALIDATOR_MESSAGE = "validatorMessage";
76
    /**
77
     * The class of the {@link Validator} coding for the constraint
78
     */
79
    public static final String ATTRIB_VALIDATOR_CLASS = "validatorClass";
80
    /**
81
     * The class of the validated entity
82
     */
83
    public static final String ATTRIB_ENTITY_CLASS = "entityClass";
84
    /**
85
     * The id of the validated entity
86
     */
87
    public static final String ATTRIB_ENTITY_ID = "entityId";
88

  
89
    private final List<EntityConstraintViolation> problems;
90

  
91
    MarkerManager(List<EntityValidation> results) {
92
        this.problems = new ArrayList<EntityConstraintViolation>();
93
        for (EntityValidation result : results) {
94
            Set<EntityConstraintViolation> problemsPerEntity = result.getEntityConstraintViolations();
95
            for (EntityConstraintViolation problem : problemsPerEntity) {
96
                problem.setEntityValidation(result);
97
                problems.add(problem);
98
            }
99
        }
100
        //MessagingUtils.info("Number of validation errors: " + problems.size());
101
    }
102

  
103
    /**
104
     * Delete all markers that refer to errors that do not exist any longer
105
     * (i.e. the corresponding database record has been deleted).
106
     *
107
     * @return The number of deleted markers
108
     *
109
     * @throws CoreException
110
     */
111
    int deleteObsoleteMarkers() throws CoreException {
112
        int i = 0;
113
        IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
114
        IMarker[] markers = root.findMarkers(MARKER_TYPE_ID, true, IResource.DEPTH_INFINITE);
115
        for (IMarker marker : markers) {
116
            if (isObsoleteMarker(marker)) {
117
                ++i;
118
                marker.delete();
119
            }
120
        }
121
        //MessagingUtils.info("Obsolete markers: " + i);
122
        return i;
123
    }
124

  
125
    /**
126
     * Create markers for new errors (i.e. no marker has been created for them
127
     * yet).
128
     *
129
     * @return The number of new markers
130
     *
131
     * @throws CoreException
132
     */
133
    int createMarkers() throws CoreException {
134
        int i = 0;
135
        IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
136
        IMarker[] markers = root.findMarkers(MARKER_TYPE_ID, true, IResource.DEPTH_INFINITE);
137
        for (EntityConstraintViolation problem : problems) {
138
            if (isNewProblem(problem, markers)) {
139
                ++i;
140
                IMarker marker = root.createMarker(MARKER_TYPE_ID);
141
                if (problem.getSeverity() == Severity.ERROR) {
142
                    marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
143
                } else if (problem.getSeverity() == Severity.WARNING) {
144
                    marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
145
                } else {
146
                    marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO);
147
                }
148
                EntityValidation result = problem.getEntityValidation();
149
                marker.setAttribute(IMarker.MESSAGE, problem.getMessage());
150
                marker.setAttribute(ATTRIB_DATABASE_ID, new Integer(problem.getId()));
151
                marker.setAttribute(ATTRIB_USER_FRIENDLY_TYPE_NAME, result.getUserFriendlyTypeName());
152
                marker.setAttribute(ATTRIB_USER_FRIENDLY_DESCRIPTION, result.getUserFriendlyDescription());
153
                marker.setAttribute(ATTRIB_USER_FRIENDLY_FIELD_NAME, problem.getUserFriendlyFieldName());
154
                marker.setAttribute(ATTRIB_VALIDATOR_MESSAGE, problem.getMessage());
155
                marker.setAttribute(ATTRIB_INVALID_VALUE, problem.getInvalidValue());
156
                marker.setAttribute(ATTRIB_VALIDATOR_CLASS, problem.getValidator());
157
                marker.setAttribute(ATTRIB_ENTITY_CLASS, result.getValidatedEntityClass());
158
                marker.setAttribute(ATTRIB_ENTITY_ID, result.getValidatedEntityId());
159
            }
160
        }
161
        //MessagingUtils.info("New problems: " + i);
162
        return i;
163
    }
164

  
165
    private boolean isObsoleteMarker(IMarker marker) throws CoreException {
166
        for (EntityConstraintViolation problem : problems) {
167
            if (isMarkerForProblem(marker, problem)) {
168
                return false;
169
            }
170
        }
171
        return true;
172
    }
173

  
174
    private static boolean isNewProblem(EntityConstraintViolation problem, IMarker[] markers) throws CoreException {
175
        for (IMarker marker : markers) {
176
            if (isMarkerForProblem(marker, problem)) {
177
                return false;
178
            }
179
        }
180
        return true;
181
    }
182

  
183
    private static boolean isMarkerForProblem(IMarker marker, EntityConstraintViolation problem) throws CoreException {
184
        if (isEqual(marker, ATTRIB_DATABASE_ID, new Integer(problem.getId()))) {
185
            return true;
186
        }
187
        EntityValidation result = problem.getEntityValidation();
188
        if (!isEqual(marker, ATTRIB_ENTITY_ID, result.getValidatedEntityId())) {
189
            return false;
190
        }
191
        if (!isEqual(marker, ATTRIB_INVALID_VALUE, problem.getInvalidValue())) {
192
            return false;
193
        }
194
        if (!isEqual(marker, ATTRIB_ENTITY_CLASS, result.getValidatedEntityClass())) {
195
            return false;
196
        }
197
        if (!isEqual(marker, ATTRIB_USER_FRIENDLY_FIELD_NAME, problem.getUserFriendlyFieldName())) {
198
            return false;
199
        }
200
        if (!isEqual(marker, ATTRIB_VALIDATOR_CLASS, problem.getValidator())) {
201
            return false;
202
        }
203
        return true;
204
    }
205

  
206
    private static boolean isEqual(IMarker marker, String attribute, Object value) throws CoreException {
207
        Object val = marker.getAttribute(attribute);
208
        boolean equal;
209
        if (val == null) {
210
            equal = value == null;
211
        } else {
212
            equal = value != null && val.equals(value);
213
        }
214
        return equal;
215
    }
289 216

  
290 217
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/validation/ValidationDaemon.java
8 8
import org.eclipse.core.runtime.Status;
9 9
import org.eclipse.core.runtime.jobs.Job;
10 10

  
11
import eu.etaxonomy.cdm.api.service.IEntityConstraintViolationService;
12
import eu.etaxonomy.cdm.api.service.IEntityValidationResultService;
13
import eu.etaxonomy.cdm.model.validation.EntityValidationResult;
11
import eu.etaxonomy.cdm.api.service.IEntityValidationService;
12
import eu.etaxonomy.cdm.model.validation.EntityValidation;
14 13
import eu.etaxonomy.taxeditor.model.MessagingUtils;
15 14
import eu.etaxonomy.taxeditor.store.CdmStore;
16 15

  
17 16
/**
18 17
 * A job that repeatedly checks the error tables and refreshes the problem
19 18
 * markers created from them.
20
 * 
19
 *
21 20
 * @author ayco_holleman
22
 * 
21
 *
23 22
 */
24 23
public class ValidationDaemon extends Job {
25

  
26 24
	@SuppressWarnings("unused")
27 25
	private static final Logger logger = Logger.getLogger(ValidationDaemon.class);
28 26

  
29
	private final IEntityValidationResultService validationResultService;
30
	
31
	@SuppressWarnings("unused")
32
	/* Not currently needed but present for future use if/when required */
33
	private final IEntityConstraintViolationService constraintViolationService;
27
	private final IEntityValidationService entityValidationService;
34 28

  
29
	// Might want to make this configurable:
30
	private int SLEEP_TIME = 5000;
31
	
35 32
	private boolean cancelRequested = false;
36 33

  
34

  
35

  
37 36
	public ValidationDaemon(){
38
		super("Initializing validation module");
39
//		StoreUtil.info("Initializing validation module");
40
		MessagingUtils.info("Initializing validation module");
41
		constraintViolationService = CdmStore.getService(IEntityConstraintViolationService.class);
42
		validationResultService = CdmStore.getService(IEntityValidationResultService.class);
37
		super("Running validation daemon");
38
		entityValidationService = CdmStore.getService(IEntityValidationService.class);
43 39
	}
44 40

  
45
	
41

  
46 42
	@Override
47 43
	protected void canceling(){
48 44
		cancelRequested = true;
......
62 58
	@Override
63 59
	protected IStatus run(IProgressMonitor monitor){
64 60
		MarkerManager markerManager;
65
		List<EntityValidationResult> results;
61
		List<EntityValidation> results;
66 62
		try {
67 63
			while (!cancelRequested) {
68
				results = validationResultService.getValidationResults();
64
				results = entityValidationService.getValidationResults();
69 65
				markerManager = new MarkerManager(results);
70 66
				markerManager.deleteObsoleteMarkers();
71 67
				markerManager.createMarkers();
72
				// Might want to make this configurable:
73
				Thread.sleep(5000);
68
				Thread.sleep(SLEEP_TIME);
74 69
			}
75
//			StoreUtil.info("Validation module stopped");
76 70
			MessagingUtils.info("Validation module stopped");
77 71
			return Status.OK_STATUS;
78 72
		}
79 73
		catch (Throwable t) {
80
//			StoreUtil.info("Validation module terminated unexpectedly: " + t.getMessage());
81 74
			MessagingUtils.info("Validation module terminated unexpectedly: " + t.getMessage());
82 75
			return Status.CANCEL_STATUS;
83 76
		}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/transientServices/TransientCdmRepository.java
24 24
import eu.etaxonomy.cdm.api.service.IDatabaseService;
25 25
import eu.etaxonomy.cdm.api.service.IDescriptionService;
26 26
import eu.etaxonomy.cdm.api.service.IEntityConstraintViolationService;
27
import eu.etaxonomy.cdm.api.service.IEntityValidationResultService;
27
import eu.etaxonomy.cdm.api.service.IEntityValidationService;
28 28
import eu.etaxonomy.cdm.api.service.IFeatureNodeService;
29 29
import eu.etaxonomy.cdm.api.service.IFeatureTreeService;
30 30
import eu.etaxonomy.cdm.api.service.IGrantedAuthorityService;
......
406 406
	}
407 407

  
408 408
	@Override
409
	public IEntityValidationResultService getEntityValidationResultService() {
410
		return defaultApplicationConfiguration.getEntityValidationResultService();
409
	public IEntityValidationService getEntityValidationService() {
410
		return defaultApplicationConfiguration.getEntityValidationService();
411 411
	}
412 412
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/transientServices/TransientOccurenceService.java
922 922
		return defaultService.findWithoutFlush(uuid);
923 923
	}
924 924

  
925
	/* (non-Javadoc)
926
	 * @see eu.etaxonomy.cdm.api.service.IOccurrenceService#listFieldUnitsByAssociatedTaxon(eu.etaxonomy.cdm.model.taxon.Taxon, java.util.List, java.util.List)
927
	 */
928 925
	@Override
929 926
	public Collection<SpecimenOrObservationBase> listFieldUnitsByAssociatedTaxon(Taxon associatedTaxon,
930 927
	        List<OrderHint> orderHints, List<String> propertyPaths) {
931 928
	    return defaultService.listFieldUnitsByAssociatedTaxon(associatedTaxon, orderHints, propertyPaths);
932 929
	}
933 930

  
934
	/* (non-Javadoc)
935
	 * @see eu.etaxonomy.cdm.api.service.IOccurrenceService#pageFieldUnitsByAssociatedTaxon(java.util.Set, eu.etaxonomy.cdm.model.taxon.Taxon, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.util.List, java.util.List)
936
	 */
937 931
	@Override
938 932
	public Pager<SpecimenOrObservationBase> pageFieldUnitsByAssociatedTaxon(
939 933
	        Set<TaxonRelationshipEdge> includeRelationships, Taxon associatedTaxon, Integer maxDepth, Integer pageSize,
......
942 936
	}
943 937

  
944 938

  
945
    /* (non-Javadoc)
946
     * @see eu.etaxonomy.cdm.api.service.IOccurrenceService#assembleDerivateHierarchyDTO(eu.etaxonomy.cdm.model.occurrence.FieldUnit, java.util.UUID)
947
     */
948 939
    @Override
949 940
    public DerivateHierarchyDTO assembleDerivateHierarchyDTO(FieldUnit fieldUnit, UUID associatedTaxonUuid) {
950 941
        return defaultService.assembleDerivateHierarchyDTO(fieldUnit, associatedTaxonUuid);
951 942
    }
952 943

  
953
    /* (non-Javadoc)
954
     * @see eu.etaxonomy.cdm.api.service.IOccurrenceService#getNonCascadedAssociatedElements(eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase, eu.etaxonomy.cdm.api.conversation.ConversationHolder)
955
     */
956 944
    @Override
957 945
    public Collection<ICdmBase> getNonCascadedAssociatedElements(SpecimenOrObservationBase<?> specimen) {
958 946
        return defaultService.getNonCascadedAssociatedElements(specimen);
eu.etaxonomy.taxeditor.navigation/src/test/resources/eu/etaxonomy/cdm/defaultApplicationContext.xml
24 24

  
25 25
    
26 26
    <!-- enable the configuration of transactional behavior based on annotations -->
27
    <tx:annotation-driven transaction-manager="transactionManager"/>      
27
    <tx:annotation-driven transaction-manager="transactionManager"/>
28
    
29
<!-- <bean id="validationManager" class="eu.etaxonomy.cdm.api.validation.ValidationManager" scope="prototype"/> -->
30
        
28 31
  
29 32

  
30 33
    
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/parser/ParseHandler.java
6 6
import java.util.ArrayList;
7 7
import java.util.List;
8 8

  
9
import eu.etaxonomy.cdm.api.service.ICommonService;
10 9
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
11 10
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
12 11
import eu.etaxonomy.cdm.model.name.NonViralName;
......
302 301
            return new ArrayList<INomenclaturalReference>();
303 302
        }
304 303
		try{
305
			return CdmStore.getService(ICommonService.class).findMatching(nomenclaturalReference, MatchStrategyConfigurator.ReferenceMatchStrategy());
304
			return CdmStore.getCommonService().findMatching(nomenclaturalReference, MatchStrategyConfigurator.ReferenceMatchStrategy());
306 305
		}catch (MatchException e) {
307 306
			MessagingUtils.error(this.getClass(), "Error finding matching references", e);
308 307
		}
......
320 319
		}
321 320

  
322 321
		try{
323
			return CdmStore.getService(ICommonService.class).findMatching(authorTeam, MatchStrategyConfigurator.TeamOrPersonMatchStrategy());
322
			return CdmStore.getCommonService().findMatching(authorTeam, MatchStrategyConfigurator.TeamOrPersonMatchStrategy());
324 323
		}catch (MatchException e) {
325 324
			MessagingUtils.error(this.getClass(), "Error finding matching authors", e);
326 325
		}
......
334 333
	private List<TaxonNameBase> findMatchingLatinNames(TaxonNameBase taxonNameBase) {
335 334

  
336 335
		try {
337
			return CdmStore.getService(ICommonService.class).findMatching(taxonNameBase, MatchStrategyConfigurator.NonViralNameMatchStrategy());
336
			return CdmStore.getCommonService().findMatching(taxonNameBase, MatchStrategyConfigurator.NonViralNameMatchStrategy());
338 337

  
339 338
		} catch (MatchException e) {
340 339
			MessagingUtils.error(this.getClass(), "Error finding matching names", e);
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java
27 27

  
28 28
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
29 29
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
30
import eu.etaxonomy.cdm.api.service.ICommonService;
30 31
import eu.etaxonomy.cdm.api.service.IService;
31 32
import eu.etaxonomy.cdm.config.ICdmSource;
32 33
import eu.etaxonomy.cdm.database.DbSchemaValidation;
......
285 286

  
286 287
		return service;
287 288
	}
289
	
290
	/**
291
	 * @see #getService(Class)
292
	 * As ICommonService is not extending IService we need a specific request here
293
	 */
294
	public static ICommonService getCommonService() {
295
		ICdmApplicationConfiguration configuration = getCurrentApplicationConfiguration();
296

  
297
		return configuration.getCommonService();
298

  
299
	}
288 300

  
289 301
	/**
290 302
	 * <p>
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStoreConnector.java
18 18
import org.eclipse.core.runtime.Status;
19 19
import org.eclipse.core.runtime.jobs.Job;
20 20
import org.eclipse.swt.widgets.Display;
21
import org.hibernate.collection.internal.AbstractPersistentCollection;
22
import org.hibernate.proxy.AbstractLazyInitializer;
23 21
import org.springframework.core.io.Resource;
24 22

  
25 23
import eu.etaxonomy.cdm.api.application.CdmApplicationController;
26 24
import eu.etaxonomy.cdm.api.application.CdmApplicationRemoteController;
27 25
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
28
import eu.etaxonomy.cdm.config.ICdmSource;
29
import eu.etaxonomy.cdm.remote.ICdmRemoteSource;
30 26
import eu.etaxonomy.cdm.config.CdmSourceException;
31
import eu.etaxonomy.cdm.database.DatabaseTypeEnum;
27
import eu.etaxonomy.cdm.config.ICdmSource;
32 28
import eu.etaxonomy.cdm.database.DbSchemaValidation;
33 29
import eu.etaxonomy.cdm.database.ICdmDataSource;
34 30
import eu.etaxonomy.cdm.model.metadata.CdmMetaData;
35
import eu.etaxonomy.cdm.model.metadata.CdmMetaData.MetaDataPropertyName;
31
import eu.etaxonomy.cdm.remote.ICdmRemoteSource;
36 32
import eu.etaxonomy.taxeditor.model.CdmProgressMonitorAdapter;
37 33
import eu.etaxonomy.taxeditor.model.MessagingUtils;
38 34
import eu.etaxonomy.taxeditor.ui.dialog.LoginDialog;
......
68 64
	public IStatus run(final IProgressMonitor monitor) {
69 65

  
70 66
		monitor.beginTask(getConnectionMessage(), 10);
71

  
67
		
72 68
		// check if database is up and running
73 69
		checkDatabaseReachable(monitor);
74 70

  
......
97 93
			CdmProgressMonitorAdapter subprogressMonitor = CdmProgressMonitorAdapter
98 94
					.CreateSubMonitor(monitor, 7);
99 95
			// This is where we instantiate the application controller
96
			int oldPriority = Thread.currentThread().getPriority();
100 97
			try {
101
				
98
				Thread.currentThread().setPriority(10);
102 99
				applicationController = getApplicationController(cdmSource,subprogressMonitor);
103
			
104 100
			} catch (Exception e) {
105 101
				if(! causeIsCancelationExceptionRecursive(e)){
106 102
					return new Status(IStatus.ERROR, "Could not connect to CDM Store", "An error occurred while trying to connect to datasource: " + cdmSource.getName(), e);
107 103
				}
108 104
			} finally {
109 105
				monitor.done();
106
				Thread.currentThread().setPriority(oldPriority);
110 107
			}
111 108
		}
112 109
		
eu.etaxonomy.taxeditor/eu.etaxonomy.taxeditor.product
14 14
   </configIni>
15 15

  
16 16
   <launcherArgs>
17
      <programArgs>-data @user.home/.cdmLibrary -Dserver_port=58080
18
-vm jre/bin</programArgs>
17
      <programArgs>-data @user.home/.cdmLibrary -Dserver_port=58080 </programArgs>
19 18
      <vmArgs>-Xmx512M -XX:MaxPermSize=256M -Dorg.eclipse.update.reconcile=false -Declipse.p2.unsignedPolicy=allow</vmArgs>
20 19
      <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac>
21 20
   </launcherArgs>

Also available in: Unified diff