List of usage examples for com.jgoodies.validation.util PropertyValidationSupport PropertyValidationSupport
public PropertyValidationSupport(Object target, String role)
From source file:org.openthinclient.console.nodes.views.DirObjectEditor.java
License:Open Source License
public ValidationResult validate() { model.triggerCommit();/* w w w .j ava2s .c o m*/ if (oldName == null) oldName = dirObject.getName(); final PropertyValidationSupport support = new PropertyValidationSupport(dirObject, dirObject.getClass().getSimpleName()); //$NON-NLS-1$ final ValidateNames validate = new ValidateNames(); final String name = dirObject.getName(); final Class<? extends DirectoryObject> dirObjectClass = dirObject.getClass(); final String result = validate.validate(name, dirObjectClass); if (result != null) support.addError("name", result); if (existingNames == null) { existingNames = new ArrayList<String>(); try { final DirContext ctx = getContext(realm); try { final String ouName = realm.getDirectory().getMapping().getTypes().get(dirObjectClass) .getBaseRDN(); if (ouName != null) { final Attributes att = new BasicAttributes(true); att.put(new BasicAttribute("cn")); final NamingEnumeration ne = ctx.search(ouName, att); while (ne.hasMoreElements()) { final SearchResult sr = (SearchResult) ne.next(); final Attributes srName = sr.getAttributes(); existingNames.add(srName.get("cn").get().toString()); } } } catch (final DirectoryException e) { e.printStackTrace(); ErrorManager.getDefault().notify(e); } finally { ctx.close(); } } catch (final NamingException e) { e.printStackTrace(); ErrorManager.getDefault().notify(e); } } if (existingNames.contains(name) && !name.equals(oldName)) support.addError("name", Messages.getString("DirObjectEditor.name.exists")); return support.getResult(); }
From source file:salomon.engine.controller.gui.domain.SolutionValidator.java
License:Open Source License
/** * Method is responsible for solution validation. * //from ww w .j a v a 2 s.c om * @see com.jgoodies.validation.Validator#validate() */ public ValidationResult validate() { LOGGER.debug("SolutionValidator.validate()"); PropertyValidationSupport support = new PropertyValidationSupport(_solutionInfo, "Solution"); // solution name validation !!! String currentSolutioName = _solutionModel.getSolutionName(); // not validate if the name is not changed - second validation fails as the name exists in DB // this may happen when editing solution if (!_solutionInfo.getName().equals(currentSolutioName)) { if (ValidationUtils.isBlank(currentSolutioName)) { support.addError("Solution Name", "is mandatory"); } else { try { boolean exists = _domainManager.exists(currentSolutioName); if (exists) { support.addError("Solution Name", "already exists"); } } catch (PlatformException e) { LOGGER.fatal("", e); support.addError("Solution Name", "INTERNAL ERROR"); } } } return support.getResult(); }
From source file:salomon.engine.controller.gui.project.ProjectValidator.java
License:Open Source License
/** * Method is responsible for project validation. * /*from w ww. j av a2s. c om*/ * @see com.jgoodies.validation.Validator#validate() */ public ValidationResult validate() { LOGGER.debug("ProjectValidator.validate()"); PropertyValidationSupport support = new PropertyValidationSupport(_projectInfo, "Project"); String currentProjectName = _projectModel.getProjectName(); // name validatation if it has changed String projectName = _projectInfo.getName(); if (projectName == null || !projectName.equals(currentProjectName)) { if (ValidationUtils.isBlank(currentProjectName)) { support.addError("Project Name", "is mandatory"); } else { try { boolean exists = _projectManager.exists(currentProjectName); if (exists) { support.addError("Project Name", "already exists"); } } catch (PlatformException e) { LOGGER.fatal("", e); support.addError("Project Name", "INTERNAL ERROR"); } } } return support.getResult(); }
From source file:salomon.engine.controller.gui.solution.SolutionValidator.java
License:Open Source License
/** * Method is responsible for solution validation. * /*from w ww. j av a 2 s . c o m*/ * @see com.jgoodies.validation.Validator#validate() */ public ValidationResult validate() { LOGGER.debug("SolutionValidator.validate()"); PropertyValidationSupport support = new PropertyValidationSupport(_solutionInfo, "Solution"); // solution name validation !!! String currentSolutioName = _solutionModel.getSolutionName(); // not validate if the name is not changed - second validation fails as the name exists in DB // this may happen when editing solution if (!_solutionInfo.getName().equals(currentSolutioName)) { if (ValidationUtils.isBlank(currentSolutioName)) { support.addError("Solution Name", "is mandatory"); } else { try { boolean exists = _solutionManager.exists(currentSolutioName); if (exists) { support.addError("Solution Name", "already exists"); } } catch (PlatformException e) { LOGGER.fatal("", e); support.addError("Solution Name", "INTERNAL ERROR"); } } } return support.getResult(); }
From source file:salomon.util.gui.validation.attributeset.AttributeSetValidator.java
License:Open Source License
/** * Method is responsible for dataset validation. * //ww w.jav a 2 s . com * @see com.jgoodies.validation.Validator#validate() */ public ValidationResult validate() { PropertyValidationSupport support = new PropertyValidationSupport(_attributeSet, "AttributeSet"); // here whole validation !!! if (ValidationUtils.isBlank(_attributeSet.getAttributeSetName())) { support.addError("AttributeSet Name", "is mandatory"); } else { try { boolean exists = exists(_attributeSet); if (exists) { support.addError("AttributeSet Name", "already exists"); } } catch (PlatformException e) { LOGGER.fatal("", e); support.addError("AttributeSet Name", "INTERNAL ERROR"); } } return support.getResult(); }
From source file:salomon.util.gui.validation.dataset.DataSetValidator.java
License:Open Source License
/** * Method is responsible for dataset validation. * /*from ww w. ja va 2 s . co m*/ * @see com.jgoodies.validation.Validator#validate() */ public ValidationResult validate() { PropertyValidationSupport support = new PropertyValidationSupport(_dataSet, "DataSet"); // here whole validation !!! if (ValidationUtils.isBlank(_dataSet.getDataSetName())) { support.addError("DataSet Name", "is mandatory"); } else { try { boolean exists = exists(_dataSet); if (exists) { support.addError("DataSet Name", "already exists"); } } catch (PlatformException e) { LOGGER.fatal("", e); support.addError("DataSet Name", "INTERNAL ERROR"); } } return support.getResult(); }