private boolean validateProblemTypeDefaultIndicator(OLEProblemType problemType) { Map<String, Boolean> criteria = new HashMap<String, Boolean>(); criteria.put( OLEConstants.OLEProblemType.PRBLM_TYPE_DEFAULT_INDICATOR, problemType.isDefaultIndicator()); List<OLEProblemType> oleProblemTypeList = (List<OLEProblemType>) KRADServiceLocator.getBusinessObjectService() .findMatching(OLEProblemType.class, criteria); boolean isDefault = problemType.isDefaultIndicator(); if (isDefault) { if (oleProblemTypeList.size() > 0) { for (OLEProblemType oleProblemType : oleProblemTypeList) { if (isDefault == oleProblemType.isDefaultIndicator()) { this.putFieldError( OLEConstants.OLEProblemType.PRBLM_TYPE_DEFAULT_INDICATOR_FIELD, OLEConstants.ERROR_DEFAULT_IND_DUPLICATE); return false; } } } } return true; }
/** * This method validates duplicate problemTypeId and return boolean value. * * @param problemType * @return boolean */ private boolean validateProblemTypeName(OLEProblemType problemType) { if (problemType.getProblemTypeName() != null) { Map<String, String> criteria = new HashMap<String, String>(); criteria.put(OLEConstants.OLEProblemType.PRBLM_TYPE_NAME, problemType.getProblemTypeName()); List<OLEProblemType> oleProblemTypeList = (List<OLEProblemType>) KRADServiceLocator.getBusinessObjectService() .findMatching(OLEProblemType.class, criteria); if ((oleProblemTypeList.size() > 0)) { for (OLEProblemType oleProblemType : oleProblemTypeList) { String problemTypeId = oleProblemType.getProblemTypeId(); if (null == problemType.getProblemTypeId() || (!problemType.getProblemTypeId().equalsIgnoreCase(problemTypeId))) { this.putFieldError( OLEConstants.OLEProblemType.PRBLM_TYPE_NAME_FIELD, OLEConstants.DUPLICATE); return false; } } } } return true; }