/** equals and hashcode work as expected for indicators */ public void indicatorEquality() throws InvalidIndicatorException { IndicatorImpl att1 = new IndicatorImpl(builder.buildIndicatorNode(id, name, code, formula, "formula_indicator")); IndicatorImpl att2 = new IndicatorImpl(builder.buildIndicatorNode(id, "", "", "", "formula_indicator")); IndicatorImpl att3 = new IndicatorImpl(builder.buildIndicatorNode("otherId", "", "", "", "formula_indicator")); assertEquals(att1, att2); assertEquals(att1.hashCode(), att2.hashCode()); assertNotEquals(att1, att3); assertFalse(att1.equals(new Object())); }
/* * (non-Jsdoc) * * @see org.talend.dataquality.indicators.impl.IndicatorImpl#handle(java.lang.Object) */ @Override public boolean handle(Object data) { super.handle(data); if (data == null) { return false; } PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance(); // } // the parameter defualtRegion is null at here, it will get an region code when the data is // guaranteed to // start with a '+' followed by the country calling code. e.g. "+86 13521588311", // "+8613521588311", // "+86 1352 1588 311". or else, it will throw Exception and as a invalid Region Code. boolean parseSuccess = true; String regionCodeForNumber = null; try { PhoneNumber phhoneNum = phoneUtil.parse(data.toString(), null); regionCodeForNumber = phoneUtil.getRegionCodeForNumber(phhoneNum); } catch (NumberParseException e) { parseSuccess = false; } Set<String> supportedCountries = phoneUtil.getSupportedRegions(); if (parseSuccess && supportedCountries.contains(regionCodeForNumber)) { this.validRegCount++; if (checkMustStoreCurrentRow() || checkMustStoreCurrentRow(drillDownValueCount)) { this.mustStoreRow = true; } } return true; }
@Override public boolean handle(Object data) { super.handle(data); if (data == null) { return false; } try { PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance(); IndicatorParameters indParameters = this.getParameters(); TextParameters textParameters = indParameters == null ? null : indParameters.getTextParameter(); String country = IndicatorHelper.getCountryCodeByParameter(textParameters); PhoneNumber phoneNumeber = phoneUtil.parse(data.toString(), country); // It only checks the length of phone numbers. In particular, it doesn't check starting digits // of the // number. if (phoneUtil.isPossibleNumber(phoneNumeber)) { this.possiblePhoneCount++; if (checkMustStoreCurrentRow() || this.checkMustStoreCurrentRow(drillDownValueCount)) { this.mustStoreRow = true; } } } catch (NumberParseException e) { return false; } return true; }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case IndicatorsPackage.VALID_REG_CODE_COUNT_INDICATOR__VALID_REG_COUNT: setValidRegCount(VALID_REG_COUNT_EDEFAULT); return; } super.eUnset(featureID); }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case IndicatorsPackage.VALID_REG_CODE_COUNT_INDICATOR__VALID_REG_COUNT: setValidRegCount((Long) newValue); return; } super.eSet(featureID, newValue); }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case IndicatorsPackage.POSSIBLE_PHONE_COUNT_INDICATOR__POSSIBLE_PHONE_COUNT: setPossiblePhoneCount(POSSIBLE_PHONE_COUNT_EDEFAULT); return; } super.eUnset(featureID); }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case IndicatorsPackage.POSSIBLE_PHONE_COUNT_INDICATOR__POSSIBLE_PHONE_COUNT: setPossiblePhoneCount((Long) newValue); return; } super.eSet(featureID, newValue); }
/* * (non-Javadoc) * * @see org.talend.dataquality.indicators.impl.IndicatorImpl#handleDrillDownData(java.lang.Object, java.util.List) */ @Override public void handleDrillDownData(Object masterObject, List<Object> inputRowList) { if (checkMustStoreCurrentRow()) { super.handleDrillDownData(masterObject, inputRowList); } // store drill dwon data for view values if (this.checkMustStoreCurrentRow(drillDownValueCount)) { if (!drillDownValuesSet.contains(masterObject)) { drillDownValueCount++; drillDownValuesSet.add(masterObject); } } }