|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ValidatorUtils | Line # 28 | 135 | 0% | 77 | 139 | 42.8% |
0.42798355
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
(92) | |||
Result | |||
0.32098764
|
org.kuali.student.lum.program.service.impl.TestProgramInfoDictionary.testMajorDisciplineInfoValidation org.kuali.student.lum.program.service.impl.TestProgramInfoDictionary.testMajorDisciplineInfoValidation | 1 PASS | |
0.21399178
|
org.kuali.student.core.statement.service.impl.TestStatementServiceImpl.testValidateReqComponent org.kuali.student.core.statement.service.impl.TestStatementServiceImpl.testValidateReqComponent | 1 PASS | |
0.21399178
|
org.kuali.student.common.validator.TestValidator.testDoubleValueRange org.kuali.student.common.validator.TestValidator.testDoubleValueRange | 1 PASS | |
0.18518518
|
org.kuali.student.core.dictionary.service.TestStatementDictionary.testRequirementComponentInfoValidation org.kuali.student.core.dictionary.service.TestStatementDictionary.testRequirementComponentInfoValidation | 1 PASS | |
0.17695473
|
org.kuali.student.common.validator.TestValidator.testNestedStructures org.kuali.student.common.validator.TestValidator.testNestedStructures | 1 PASS | |
0.11934157
|
org.kuali.student.common.validator.TestValidator.testMinDateValue org.kuali.student.common.validator.TestValidator.testMinDateValue | 1 PASS | |
0.10288066
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testCluCrud org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testCluCrud | 1 PASS | |
0.10288066
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testVersioning org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testVersioning | 1 PASS | |
0.10288066
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testCluValidation org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testCluValidation | 1 PASS | |
0.06584362
|
org.kuali.student.common.validator.TestValidator.testLengthRange org.kuali.student.common.validator.TestValidator.testLengthRange | 1 PASS | |
0.06584362
|
org.kuali.student.common.validator.TestValidator.testValidChars org.kuali.student.common.validator.TestValidator.testValidChars | 1 PASS | |
0.06584362
|
org.kuali.student.common.validator.TestValidator.testMinLength org.kuali.student.common.validator.TestValidator.testMinLength | 1 PASS | |
0.06584362
|
org.kuali.student.common.validator.TestValidator.testMaxLength org.kuali.student.common.validator.TestValidator.testMaxLength | 1 PASS | |
0.06584362
|
org.kuali.student.common.validator.TestValidator.testRequired org.kuali.student.common.validator.TestValidator.testRequired | 1 PASS | |
0.057613168
|
org.kuali.student.lum.course.service.impl.TestCourseInfoDictionary.testCourseInfoValidation org.kuali.student.lum.course.service.impl.TestCourseInfoDictionary.testCourseInfoValidation | 3 FAIL | |
0.057613168
|
org.kuali.student.core.dictionary.service.TestProposalInfoDictionary.testProposalInfoValidation org.kuali.student.core.dictionary.service.TestProposalInfoDictionary.testProposalInfoValidation | 1 PASS | |
0.04526749
|
org.kuali.student.lum.course.service.impl.TestCluInfoDictionary.testCluInfoValidation org.kuali.student.lum.course.service.impl.TestCluInfoDictionary.testCluInfoValidation | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddClusToCluSet_DuplicateCluId org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddClusToCluSet_DuplicateCluId | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testUpdateCluSet_AddClu org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testUpdateCluSet_AddClu | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testLoCategory org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testLoCategory | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddCluSetsToCluSet_NestedCircularRelationshipException org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddCluSetsToCluSet_NestedCircularRelationshipException | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddCluSetToCluSet_InvalidCluSetId org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddCluSetToCluSet_InvalidCluSetId | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddCluSetToCluSet_NestedCircularRelationshipException org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddCluSetToCluSet_NestedCircularRelationshipException | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testGetDynamicCluSet_Simple org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testGetDynamicCluSet_Simple | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddCluSetToCluSet_DuplicateCluSetId org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddCluSetToCluSet_DuplicateCluSetId | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddCluSetsToCluSet_CircularRelationshipException org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddCluSetsToCluSet_CircularRelationshipException | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testUpdateCluSet_ClearClus org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testUpdateCluSet_ClearClus | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testGetCluSetTreeView_dynamicCluSet org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testGetCluSetTreeView_dynamicCluSet | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddClusToCluSet org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddClusToCluSet | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lrc.service.impl.TestLrcServiceImpl.testResultComponentCrud org.kuali.student.lum.lrc.service.impl.TestLrcServiceImpl.testResultComponentCrud | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testUpdateCluSet_RemoveClu org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testUpdateCluSet_RemoveClu | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testGetDynamicCluSet org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testGetDynamicCluSet | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testUpdateCluSet_ClearCluSets org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testUpdateCluSet_ClearCluSets | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddCluSetsToCluSet_InvalidCluSetId org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddCluSetsToCluSet_InvalidCluSetId | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddCluSetToCluSet org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddCluSetToCluSet | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddCluToCluSet_DuplicateCluId org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddCluToCluSet_DuplicateCluId | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddCluToCluSet org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddCluToCluSet | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testCluSetCrud org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testCluSetCrud | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddCluSetsToCluSet org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddCluSetsToCluSet | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddCluSetToCluSet_CircularRelationshipException org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddCluSetToCluSet_CircularRelationshipException | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testUpdateDynamicCluSet org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testUpdateDynamicCluSet | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testCreateDynamicCluSet org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testCreateDynamicCluSet | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testDeleteCluSet org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testDeleteCluSet | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddClusToCluSet_InvalidCluId org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddClusToCluSet_InvalidCluId | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testUpdateCluSet_VersionMismatch org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testUpdateCluSet_VersionMismatch | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testRemoveCluFromCluSet org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testRemoveCluFromCluSet | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testUpdateCluSet_removeCluSets org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testUpdateCluSet_removeCluSets | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testDisallowLoWEmptyDesc org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testDisallowLoWEmptyDesc | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testLo org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testLo | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testCreateDynamicCluSet_Simple org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testCreateDynamicCluSet_Simple | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddCluSetsToCluSet_DuplicateCluSetId org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testAddCluSetsToCluSet_DuplicateCluSetId | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testUpdateCluSet_AddCluSets org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testUpdateCluSet_AddCluSets | 1 PASS | |
0.04526749
|
org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testRemoveCluSetFromCluSet org.kuali.student.lum.lu.service.impl.TestLuServiceImpl.testRemoveCluSetFromCluSet | 1 PASS | |
0.020576132
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetVersions org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetVersions | 1 PASS | |
0.020576132
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testDeleteCourseStatement org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testDeleteCourseStatement | 1 PASS | |
0.020576132
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCourseVersioning org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCourseVersioning | 1 PASS | |
0.020576132
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateMajorDiscipline org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateMajorDiscipline | 1 PASS | |
0.020576132
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCreditOptions org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCreditOptions | 1 PASS | |
0.020576132
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetCurrentVersion org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetCurrentVersion | 1 PASS | |
0.020576132
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testUpdateCourseStatement org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testUpdateCourseStatement | 1 PASS | |
0.020576132
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testDeleteProgramRequirement org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testDeleteProgramRequirement | 1 PASS | |
0.020576132
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetVersionsInDateRange org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetVersionsInDateRange | 1 PASS | |
0.020576132
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testDeleteCourse org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testDeleteCourse | 1 PASS | |
0.020576132
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetCurrentVersionOnDate org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetCurrentVersionOnDate | 1 PASS | |
0.020576132
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateProgramRequirement org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateProgramRequirement | 1 PASS | |
0.020576132
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateBaccCredentialProgram org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateBaccCredentialProgram | 1 PASS | |
0.020576132
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCoreProgramVersioning org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCoreProgramVersioning | 1 PASS | |
0.020576132
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateVariationsByMajorDiscipline org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateVariationsByMajorDiscipline | 1 PASS | |
0.020576132
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testDeleteVariationsByMajorDiscipline org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testDeleteVariationsByMajorDiscipline | 1 PASS | |
0.020576132
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateBaccCredentialProgram org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateBaccCredentialProgram | 1 PASS | |
0.020576132
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCreateCourseStatement org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCreateCourseStatement | 1 PASS | |
0.020576132
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreditsProgramRequirement org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreditsProgramRequirement | 1 PASS | |
0.020576132
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testUpdateCourse org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testUpdateCourse | 1 PASS | |
0.020576132
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCourseCrossListing org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCourseCrossListing | 1 PASS | |
0.020576132
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testDynamicAttributes org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testDynamicAttributes | 1 PASS | |
0.020576132
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateMajorDiscipline org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateMajorDiscipline | 1 PASS | |
0.020576132
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateCoreProgram org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateCoreProgram | 1 PASS | |
0.020576132
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testDeleteCoreProgram org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testDeleteCoreProgram | 1 PASS | |
0.020576132
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateMajorDisciplineRemoveRule org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateMajorDisciplineRemoveRule | 1 PASS | |
0.020576132
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateCoreProgram org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateCoreProgram | 1 PASS | |
0.020576132
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetFirstVersion org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetFirstVersion | 1 PASS | |
0.020576132
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testMajorDisciplineVersioning org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testMajorDisciplineVersioning | 1 PASS | |
0.020576132
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetCourse org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetCourse | 1 PASS | |
0.020576132
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateMajorDisciplineDeleteRule org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testCreateMajorDisciplineDeleteRule | 1 PASS | |
0.020576132
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCreateCourseStatement_duplicateTree org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCreateCourseStatement_duplicateTree | 1 PASS | |
0.020576132
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCreateCourse org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCreateCourse | 1 PASS | |
0.020576132
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateVariationsByMajorDiscipline org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateVariationsByMajorDiscipline | 1 PASS | |
0.020576132
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetVersionBySequenceNumber org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetVersionBySequenceNumber | 1 PASS | |
0.020576132
|
org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateProgramRequirement org.kuali.student.lum.program.service.impl.TestProgramServiceImpl.testUpdateProgramRequirement | 1 PASS | |
0.016460905
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testCreateLoLoRelation org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testCreateLoLoRelation | 1 PASS | |
0.016460905
|
org.kuali.student.core.dictionary.service.TestBaseDictionary.testValidCharsConstraints org.kuali.student.core.dictionary.service.TestBaseDictionary.testValidCharsConstraints | 1 PASS | |
0.016460905
|
org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testDisallowLoCategoryWEmptyName org.kuali.student.lum.lo.service.impl.TestLearningObjectiveServiceImpl.testDisallowLoCategoryWEmptyName | 1 PASS | |
1 | /** | |
2 | * Copyright 2010 The Kuali Foundation Licensed under the | |
3 | * Educational Community License, Version 2.0 (the "License"); you may | |
4 | * not use this file except in compliance with the License. You may | |
5 | * obtain a copy of the License at | |
6 | * | |
7 | * http://www.osedu.org/licenses/ECL-2.0 | |
8 | * | |
9 | * Unless required by applicable law or agreed to in writing, | |
10 | * software distributed under the License is distributed on an "AS IS" | |
11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | |
12 | * or implied. See the License for the specific language governing | |
13 | * permissions and limitations under the License. | |
14 | */ | |
15 | ||
16 | package org.kuali.student.common.validator; | |
17 | ||
18 | import java.util.Collection; | |
19 | import java.util.Date; | |
20 | import java.util.List; | |
21 | ||
22 | import org.kuali.student.common.dictionary.dto.DataType; | |
23 | import org.kuali.student.common.dictionary.dto.FieldDefinition; | |
24 | import org.kuali.student.common.dictionary.dto.ObjectStructureDefinition; | |
25 | import org.kuali.student.common.validation.dto.ValidationResultInfo; | |
26 | import org.kuali.student.common.validation.dto.ValidationResultInfo.ErrorLevel; | |
27 | ||
28 | public class ValidatorUtils { | |
29 | ||
30 | 396 | public static boolean compareValues(Object value1, Object value2, |
31 | DataType dataType, String operator, boolean isCaseSensitive, DateParser dateParser) { | |
32 | ||
33 | 396 | boolean result = false; |
34 | 396 | Integer compareResult = null; |
35 | 396 | if("has_value".equalsIgnoreCase(operator)){ |
36 | 6 | if(value1==null){ |
37 | 0 | return "false".equals(value2.toString().toLowerCase()); |
38 | } | |
39 | 6 | if(value1 instanceof Collection && ((Collection<?>) value1).isEmpty()){ |
40 | 0 | return "false".equals(value2.toString().toLowerCase()); |
41 | } | |
42 | 6 | return "true".equals(value2.toString().toLowerCase()); |
43 | } | |
44 | // Convert objects into appropriate data types | |
45 | 390 | if (null != dataType) { |
46 | 378 | if (DataType.STRING.equals(dataType)) { |
47 | 378 | String v1 = getString(value1); |
48 | 378 | String v2 = getString(value2); |
49 | ||
50 | 378 | if(!isCaseSensitive) { |
51 | 378 | v1 = v1.toUpperCase(); |
52 | 378 | v2 = v2.toUpperCase(); |
53 | } | |
54 | ||
55 | 378 | compareResult = v1.compareTo(v2); |
56 | 0 | } else if (DataType.INTEGER.equals(dataType)) { |
57 | 0 | Integer v1 = getInteger(value1); |
58 | 0 | Integer v2 = getInteger(value2); |
59 | 0 | compareResult = v1.compareTo(v2); |
60 | 0 | } else if (DataType.LONG.equals(dataType)) { |
61 | 0 | Long v1 = getLong(value1); |
62 | 0 | Long v2 = getLong(value2); |
63 | 0 | compareResult = v1.compareTo(v2); |
64 | 0 | } else if (DataType.DOUBLE.equals(dataType)) { |
65 | 0 | Double v1 = getDouble(value1); |
66 | 0 | Double v2 = getDouble(value2); |
67 | 0 | compareResult = v1.compareTo(v2); |
68 | 0 | } else if (DataType.FLOAT.equals(dataType)) { |
69 | 0 | Float v1 = getFloat(value1); |
70 | 0 | Float v2 = getFloat(value2); |
71 | 0 | compareResult = v1.compareTo(v2); |
72 | 0 | } else if (DataType.BOOLEAN.equals(dataType)) { |
73 | 0 | Boolean v1 = getBoolean(value1); |
74 | 0 | Boolean v2 = getBoolean(value2); |
75 | 0 | compareResult = v1.compareTo(v2); |
76 | 0 | } else if (DataType.DATE.equals(dataType)) { |
77 | 0 | Date v1 = getDate(value1, dateParser); |
78 | 0 | Date v2 = getDate(value2, dateParser); |
79 | 0 | compareResult = v1.compareTo(v2); |
80 | } | |
81 | } | |
82 | ||
83 | 390 | if (null != compareResult) { |
84 | 378 | if (("equals".equalsIgnoreCase(operator) |
85 | || "greater_than_equal".equalsIgnoreCase(operator) || "less_than_equal" | |
86 | .equalsIgnoreCase(operator)) | |
87 | && 0 == compareResult) { | |
88 | 6 | result = true; |
89 | } | |
90 | ||
91 | 378 | if (("not_equal".equalsIgnoreCase (operator) |
92 | || "greater_than".equalsIgnoreCase(operator) || "greater_than_equal".equalsIgnoreCase(operator)) && compareResult >= 1) { | |
93 | 0 | result = true; |
94 | } | |
95 | ||
96 | 378 | if (("not_equal".equalsIgnoreCase (operator) |
97 | || "less_than".equalsIgnoreCase(operator)|| "less_than_equal".equalsIgnoreCase(operator)) && compareResult <= -1) { | |
98 | 0 | result = true; |
99 | } | |
100 | } | |
101 | ||
102 | 390 | return result; |
103 | } | |
104 | ||
105 | 106 | public static Integer getInteger(Object o) { |
106 | 106 | Integer result = null; |
107 | 106 | if (o instanceof Integer) |
108 | 0 | return (Integer) o; |
109 | 106 | if (o == null) |
110 | 106 | return null; |
111 | 0 | if (o instanceof Number) |
112 | 0 | return ((Number) o).intValue(); |
113 | 0 | String s = o.toString(); |
114 | 0 | if (s != null && s.trim().length() > 0) { |
115 | 0 | result = Integer.valueOf(s.trim()); |
116 | } | |
117 | 0 | return result; |
118 | } | |
119 | ||
120 | 62 | public static Long getLong(Object o) { |
121 | 62 | Long result = null; |
122 | 62 | if (o instanceof Long) |
123 | 0 | return (Long) o; |
124 | 62 | if (o == null) |
125 | 62 | return null; |
126 | 0 | if (o instanceof Number) |
127 | 0 | return ((Number) o).longValue(); |
128 | 0 | String s = o.toString(); |
129 | 0 | if (s != null && s.trim().length() > 0) { |
130 | 0 | result = Long.valueOf(s.trim()); |
131 | } | |
132 | 0 | return result; |
133 | } | |
134 | ||
135 | 0 | public static Float getFloat(Object o) { |
136 | 0 | Float result = null; |
137 | 0 | if (o instanceof Float) |
138 | 0 | return (Float) o; |
139 | 0 | if (o == null) |
140 | 0 | return null; |
141 | 0 | if (o instanceof Number) |
142 | 0 | return ((Number) o).floatValue(); |
143 | 0 | String s = o.toString(); |
144 | 0 | if (s != null && s.trim().length() > 0) { |
145 | 0 | result = Float.valueOf(s.trim()); |
146 | } | |
147 | 0 | return result; |
148 | } | |
149 | ||
150 | 2 | public static Double getDouble(Object o) { |
151 | 2 | Double result = null; |
152 | 2 | if (o instanceof Double) |
153 | 0 | return (Double) o; |
154 | 2 | if (o == null) |
155 | 0 | return null; |
156 | 2 | if (o instanceof Number) |
157 | 0 | return ((Number) o).doubleValue(); |
158 | 2 | String s = o.toString(); |
159 | 2 | if (s != null && s.trim().length() > 0) { |
160 | 2 | result = Double.valueOf(s.trim()); |
161 | } | |
162 | 2 | return result; |
163 | } | |
164 | ||
165 | 1026 | public static Date getDate(Object o, DateParser dateParser) { |
166 | 1026 | Date result = null; |
167 | 1026 | if (o instanceof Date) |
168 | 0 | return (Date) o; |
169 | 1026 | if (o == null) |
170 | 1021 | return null; |
171 | 5 | String s = o.toString(); |
172 | 5 | if (s != null && s.trim().length() > 0) { |
173 | 5 | result = dateParser.parseDate(s.trim()); |
174 | } | |
175 | 5 | return result; |
176 | } | |
177 | ||
178 | 2205 | public static String getString(Object o) { |
179 | 2205 | if (o instanceof String) |
180 | 2204 | return (String) o; |
181 | 1 | if (o == null) |
182 | 0 | return null; |
183 | 1 | return o.toString(); |
184 | } | |
185 | ||
186 | 0 | public static Boolean getBoolean(Object o) { |
187 | 0 | Boolean result = null; |
188 | 0 | if (o instanceof Boolean) |
189 | 0 | return (Boolean) o; |
190 | 0 | if (o == null) |
191 | 0 | return null; |
192 | 0 | String s = o.toString(); |
193 | 0 | if (s != null && s.trim().length() > 0) { |
194 | 0 | result = Boolean.parseBoolean(s.trim()); |
195 | } | |
196 | 0 | return result; |
197 | } | |
198 | ||
199 | /** | |
200 | * Traverses the dictionary ObjectStructure to find the field with the match | |
201 | * key, type and state | |
202 | * The key has to relative to the current object structure that is being traversed. | |
203 | * example: current object structure is ActivityInfo and if we want to lookup | |
204 | * the academicSubjectorgId, then <property name="fieldPath" value="academicSubjectOrgs.orgId"/> | |
205 | * The current object structure starts from the field on which the constraint is applied on. | |
206 | * If we want to address fields outside of this object structure we ll need to pass in the | |
207 | * dictionary context. | |
208 | * @param key | |
209 | * @param type | |
210 | * @param state | |
211 | * @param objStructure | |
212 | * @return | |
213 | */ | |
214 | 159 | public static FieldDefinition getField(String key, ObjectStructureDefinition objStructure) { |
215 | 159 | String[] lookupPathTokens = getPathTokens(key); |
216 | 173 | for(int i = 0; i < lookupPathTokens.length; i++) { |
217 | 159 | for (FieldDefinition f : objStructure.getAttributes()) { |
218 | 4477 | if (f.getName().equals(lookupPathTokens[i])) { |
219 | 145 | if(i==lookupPathTokens.length-1){ |
220 | 145 | return f; |
221 | } | |
222 | else{ | |
223 | 0 | objStructure = f.getDataObjectStructure(); |
224 | 0 | break; |
225 | } | |
226 | ||
227 | } | |
228 | } | |
229 | } | |
230 | 14 | return null; |
231 | } | |
232 | ||
233 | 159 | private static String[] getPathTokens(String fieldPath) { |
234 | 159 | return (fieldPath != null && fieldPath.contains(".") ? fieldPath.split("\\.") : new String[]{fieldPath}); |
235 | } | |
236 | ||
237 | /** | |
238 | * Inspect the validation result to determine if there are any errors. | |
239 | * | |
240 | * @param validationResults | |
241 | * @return true if at least one validation result is an error. | |
242 | */ | |
243 | 45 | public static boolean hasErrors(List<ValidationResultInfo> validationResults){ |
244 | 45 | if (validationResults !=null){ |
245 | 45 | for (ValidationResultInfo vr:validationResults){ |
246 | 0 | if (vr.getErrorLevel() == ErrorLevel.ERROR){ |
247 | 0 | return true; |
248 | } | |
249 | } | |
250 | } | |
251 | ||
252 | 45 | return false; |
253 | } | |
254 | ||
255 | /** | |
256 | * Inspect the validation result to determine if there are any errors. | |
257 | * | |
258 | * @param validationResults | |
259 | * @return true if at least one validation result is an error. | |
260 | */ | |
261 | 0 | public static boolean hasWarnings(List<ValidationResultInfo> validationResults){ |
262 | 0 | if (validationResults !=null){ |
263 | 0 | for (ValidationResultInfo vr:validationResults){ |
264 | 0 | if (vr.getErrorLevel() == ErrorLevel.WARN){ |
265 | 0 | return true; |
266 | } | |
267 | } | |
268 | } | |
269 | ||
270 | 0 | return false; |
271 | } | |
272 | ||
273 | } | |
274 |
|