use of org.talend.mdm.repository.model.mdmserverobject.WSWhereConditionE in project tmdm-studio-se by Talend.
the class ViewOperatorUpdatorTest method test.
@Test
public void test() {
WSViewItem wsViewItem = MdmpropertiesFactory.eINSTANCE.createWSViewItem();
WSViewE wsViewE = MdmserverobjectFactory.eINSTANCE.createWSViewE();
wsViewItem.setWsView(wsViewE);
// $NON-NLS-1$
String customAppend = "_Customed";
String customContianOperator = WSWhereOperator.CONTAINS.name() + customAppend;
WSWhereConditionE conditionA = MdmserverobjectFactory.eINSTANCE.createWSWhereConditionE();
wsViewE.getWhereConditions().add(conditionA);
WSWhereOperatorE operatorA = MdmserverobjectFactory.eINSTANCE.createWSWhereOperatorE();
operatorA.setValue(customContianOperator);
conditionA.setOperator(operatorA);
WSWhereConditionE conditionB = MdmserverobjectFactory.eINSTANCE.createWSWhereConditionE();
wsViewE.getWhereConditions().add(conditionB);
WSWhereOperatorE operatorB = MdmserverobjectFactory.eINSTANCE.createWSWhereOperatorE();
operatorB.setValue(WSWhereOperator.JOIN.name());
conditionB.setOperator(operatorB);
boolean updated = new ViewOperatorUpdator().updateConditionOperator(wsViewItem);
assertTrue(updated);
assertEquals(WSWhereOperator.CONTAINS.name(), operatorA.getValue());
assertEquals(WSWhereOperator.JOIN.name(), operatorB.getValue());
}
use of org.talend.mdm.repository.model.mdmserverobject.WSWhereConditionE in project tmdm-studio-se by Talend.
the class ViewOperatorUpdator method updateConditionOperator.
public boolean updateConditionOperator(Item item) {
boolean modified = false;
List<String> opers = getOperators();
if (item != null && item instanceof WSViewItem) {
WSViewItem viewItem = (WSViewItem) item;
WSViewE wsView = viewItem.getWsView();
EList<WSWhereConditionE> whereConditions = wsView.getWhereConditions();
if (whereConditions != null) {
for (WSWhereConditionE whereConditionE : whereConditions) {
WSWhereOperatorE operator = whereConditionE.getOperator();
if (!opers.contains(operator.getValue())) {
operator.setValue(WSWhereOperator.CONTAINS.name());
modified = true;
}
}
}
}
return modified;
}
use of org.talend.mdm.repository.model.mdmserverobject.WSWhereConditionE 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;
}
Aggregations