Search in sources :

Example 11 with ValidationMessage

use of org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage in project webtools.sourceediting by eclipse.

the class Validator2 method validate.

@Override
public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
    /*
		 * String s; switch(kind) { case IResourceDelta.ADDED: s = "added"; break; case IResourceDelta.CHANGED: s = "CHANGED"; break; case IResourceDelta.CONTENT: s = "CONTENT"; break; case
		 * IResourceDelta.REMOVED: s = "REMOVED"; break; default: s = "other"; } System.out.println(s);
		 */
    ValidationResult result = new ValidationResult();
    if (resource.getType() == IResource.FILE) {
        IFile file = (IFile) resource;
        ValidationReport report = doValidation(file, kind, state, monitor);
        StylesheetModel stylesheet = XSLCore.getInstance().getStylesheet(file);
        IFile[] dependencies = stylesheet.getFileDependencies().toArray(new IFile[0]);
        result.setDependsOn(dependencies);
        for (ValidationMessage message : report.getValidationMessages()) {
            XSLValidationMessage xslMsg = (XSLValidationMessage) message;
            ValidatorMessage msg = ValidatorMessage.create(message.getMessage(), resource);
            // $NON-NLS-1$
            msg.setAttribute("lineNumber", xslMsg.getLineNumber());
            // $NON-NLS-1$
            msg.setAttribute("severity", xslMsg.getSeverity());
            result.add(msg);
        }
    }
    return result;
}
Also used : XSLValidationMessage(org.eclipse.wst.xsl.core.internal.validation.XSLValidationMessage) IFile(org.eclipse.core.resources.IFile) XSLValidationMessage(org.eclipse.wst.xsl.core.internal.validation.XSLValidationMessage) ValidationMessage(org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage) ValidationReport(org.eclipse.wst.xml.core.internal.validation.core.ValidationReport) ValidationResult(org.eclipse.wst.validation.ValidationResult) StylesheetModel(org.eclipse.wst.xsl.core.model.StylesheetModel) ValidatorMessage(org.eclipse.wst.validation.ValidatorMessage)

Example 12 with ValidationMessage

use of org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage in project tmdm-studio-se by Talend.

the class ViewValidator method validate.

@Override
public ValidationReport validate(String uri, InputStream inputstream, NestedValidatorContext context) {
    ViewValidationReport viewValidationReport = new ViewValidationReport(uri);
    // $NON-NLS-1$
    String fileName = uri.substring(uri.lastIndexOf("/") + 1);
    String viewName = getViewName(fileName);
    // $NON-NLS-1$ //$NON-NLS-2$
    viewName = viewName.replace("$", "#");
    IRepositoryViewObject viewObj = RepositoryResourceUtil.findViewObjectByName(IServerObjectRepositoryType.TYPE_VIEW, viewName);
    if (viewObj != null) {
        WSViewItem item = (WSViewItem) viewObj.getProperty().getItem();
        WSViewE view = (WSViewE) item.getMDMServerObject();
        EList<WSWhereConditionE> whereConditions = view.getWhereConditions();
        if (whereConditions != null && whereConditions.size() > 0) {
            for (WSWhereConditionE conditionE : whereConditions) {
                String userVarValue = conditionE.getRightValueOrPath();
                boolean isValid = UserVarValueValidator.validate(userVarValue);
                if (!isValid) {
                    String validateMsg = Messages.bind(Messages.ViewValidator_error, userVarValue, viewName);
                    viewValidationReport.addValidationMessage(new ValidationMessage(validateMsg, -1, -1));
                }
            }
        }
    }
    return viewValidationReport;
}
Also used : ValidationMessage(org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage) WSViewItem(org.talend.mdm.repository.model.mdmproperties.WSViewItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) WSViewE(org.talend.mdm.repository.model.mdmserverobject.WSViewE) WSWhereConditionE(org.talend.mdm.repository.model.mdmserverobject.WSWhereConditionE)

Aggregations

ValidationMessage (org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage)12 Map (java.util.Map)3 ValidationReport (org.eclipse.wst.xml.core.internal.validation.core.ValidationReport)3 XSLValidationMessage (org.eclipse.wst.xsl.core.internal.validation.XSLValidationMessage)3 HashMap (java.util.HashMap)2 IFile (org.eclipse.core.resources.IFile)2 Message (org.eclipse.wst.validation.internal.core.Message)2 DataOutputStream (java.io.DataOutputStream)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 Iterator (java.util.Iterator)1 List (java.util.List)1 IMarker (org.eclipse.core.resources.IMarker)1 IResource (org.eclipse.core.resources.IResource)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 ValidationResult (org.eclipse.wst.validation.ValidationResult)1 ValidatorMessage (org.eclipse.wst.validation.ValidatorMessage)1 ErrorMessageInformation (org.eclipse.wst.xml.core.internal.validation.errorcustomization.ErrorCustomizationManager.ErrorMessageInformation)1