Search in sources :

Example 1 with ValidationCancelledException

use of org.eclipse.jst.j2ee.model.internal.validation.ValidationCancelledException in project jbosstools-hibernate by jbosstools.

the class HibernateClassRef method validate.

/* (non-Javadoc)
	 * @see org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericClassRef#validate(java.util.List, org.eclipse.wst.validation.internal.provisional.core.IReporter)
	 */
@Override
public void validate(List<IMessage> messages, IReporter reporter) {
    if (reporter.isCancelled()) {
        throw new ValidationCancelledException();
    }
    if (StringTools.isBlank(this.className)) {
        messages.add(buildValidationMessage(JptJpaCoreValidationMessages.PERSISTENCE_UNIT_UNSPECIFIED_CLASS, this.getValidationTextRange()));
        return;
    }
    if (this.getJavaPersistentType() == null && this.javaPackageInfo == null) {
        messages.add(buildValidationMessage(JptJpaCoreValidationMessages.PERSISTENCE_UNIT_NONEXISTENT_CLASS, new String[] { this.getJavaClassName() }, this.getValidationTextRange()));
        return;
    }
    if (this.getJavaPersistentType() != null) {
        // 190062 validate Java class only if this is the only reference to it
        // i.e. the persistence.xml ref is the only ref - none of the mapping
        // files reference the same class
        boolean validateJavaPersistentType = true;
        for (MappingFileRef mappingFileRef : this.getPersistenceUnit().getMappingFileRefsContaining(this.getJavaClassName())) {
            validateJavaPersistentType = false;
            messages.add(buildValidationMessage(JptJpaCoreValidationMessages.PERSISTENCE_UNIT_REDUNDANT_CLASS, new String[] { this.getJavaClassName(), mappingFileRef.getFileName() }, this.getValidationTextRange()));
        }
        if (validateJavaPersistentType) {
            this.validateJavaManagedType(messages, reporter);
        }
    } else {
        validatePackageInfo(messages, reporter);
    }
}
Also used : ValidationCancelledException(org.eclipse.jst.j2ee.model.internal.validation.ValidationCancelledException) MappingFileRef(org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef)

Aggregations

MappingFileRef (org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef)1 ValidationCancelledException (org.eclipse.jst.j2ee.model.internal.validation.ValidationCancelledException)1