Skip to main content
summaryrefslogtreecommitdiffstats
blob: 4f5b65a73583fc2d6e540fb183e016c79a5ca857 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*******************************************************************************
 * Copyright (c) 2007 Oracle. All rights reserved.
 * This program and the accompanying materials are made available under the terms of
 * the Eclipse Public License v1.0, which accompanies this distribution and is available at
 * http://www.eclipse.org/legal/epl-v10.html.
 * 
 * Contributors:
 *     Oracle - initial API and implementation
 ******************************************************************************/
package org.eclipse.jpt.core.internal.validation;

import java.util.Iterator;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.jpt.core.internal.IJpaProject;
import org.eclipse.wst.validation.internal.core.Message;
import org.eclipse.wst.validation.internal.core.ValidationException;
import org.eclipse.wst.validation.internal.operations.IWorkbenchContext;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
import org.eclipse.wst.validation.internal.provisional.core.IValidatorJob;

public class JpaValidator implements IValidatorJob
{
	public ISchedulingRule getSchedulingRule(IValidationContext helper) {
		// don't know what to return here.  my guess is that we want to return
		// the resource that is possibly being changed during our validation,
		// and since many resources in the project may be changed during this
		// validation, returning the project makes the most sense.
		return ((IWorkbenchContext) helper).getProject();
	}

	public IStatus validateInJob(IValidationContext helper, IReporter reporter) throws ValidationException {
		JpaHelper jpaHelper = (JpaHelper) helper;
		IJpaProject jpaProject = jpaHelper.getJpaProject();
		
		reporter.removeAllMessages(this);
		
		for (Iterator stream = jpaProject.validationMessages(); stream.hasNext(); ) {
			reporter.addMessage(this, (Message) stream.next());
		}
		
		return OK_STATUS;
	}

	public void cleanup(IReporter reporter) {
	// TODO Auto-generated method stub
		return;
	}

	public void validate(IValidationContext helper, IReporter reporter) throws ValidationException {
		validateInJob(helper, reporter);
	}
}

Back to the top