use of org.talend.core.model.properties.ValidationRulesConnectionItem in project tdi-studio-se by Talend.
the class ValidationRulesUtil method getRelatedValidationRuleObjs.
public static List<IRepositoryViewObject> getRelatedValidationRuleObjs(String schemaId) {
List<IRepositoryViewObject> rulesObjs = new ArrayList<IRepositoryViewObject>();
if (schemaId != null) {
try {
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
List<IRepositoryViewObject> members = factory.getAll(ERepositoryObjectType.METADATA_VALIDATION_RULES);
if (members != null && members.size() > 0) {
for (IRepositoryViewObject member : members) {
if (member != null && member.getProperty() != null) {
Item item = member.getProperty().getItem();
if (item != null && item instanceof ValidationRulesConnectionItem) {
ValidationRulesConnectionItem validItem = (ValidationRulesConnectionItem) item;
ValidationRulesConnection connection = (ValidationRulesConnection) validItem.getConnection();
if (connection != null && !rulesObjs.contains(member)) {
rulesObjs.add(member);
}
}
}
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
return rulesObjs;
}
use of org.talend.core.model.properties.ValidationRulesConnectionItem in project tdi-studio-se by Talend.
the class ComponentChooseDialog method createValidationRule.
/**
* DOC ycbai Comment method "createValidationRule".
*
* @param dragModel
* @param targetEditPart
*/
private void createValidationRule(Object dragModel, EditPart targetEditPart) {
if (!(dragModel instanceof RepositoryNode && targetEditPart instanceof NodeContainerPart)) {
return;
}
RepositoryNode dragNode = (RepositoryNode) dragModel;
NodeContainerPart nodePart = (NodeContainerPart) targetEditPart;
if (dragNode.getObject().getProperty().getItem() instanceof ValidationRulesConnectionItem) {
Node node = (Node) nodePart.getNodePart().getModel();
List<IRepositoryViewObject> valRuleObjs = ValidationRulesUtil.getRelatedValidationRuleObjs(node);
IRepositoryViewObject valRuleObj = dragNode.getObject();
String schemaType = (String) node.getPropertyValue(EParameterName.SCHEMA_TYPE.getName());
if (EmfComponent.BUILTIN.equals(schemaType) || !ValidationRulesUtil.isCurrentValRuleObjInList(valRuleObjs, valRuleObj)) {
MessageDialog.openWarning(editor.getSite().getShell(), //$NON-NLS-1$
Messages.getString("SchemaTypeController.validationrule.title.warn"), //$NON-NLS-1$
Messages.getString("SchemaTypeController.validationrule.cannotApplyValMsg"));
return;
}
CompoundCommand cc = new CompoundCommand();
cc.add(new PropertyChangeCommand(node, EParameterName.VALIDATION_RULES.getName(), true));
cc.add(new //$NON-NLS-1$
ChangeValuesFromRepository(//$NON-NLS-1$
node, //$NON-NLS-1$
null, //$NON-NLS-1$
"VALIDATION_RULE_TYPE:VALIDATION_RULE_TYPE", EmfComponent.REPOSITORY));
cc.add(new PropertyChangeCommand(node, EParameterName.REPOSITORY_VALIDATION_RULE_TYPE.getName(), valRuleObj.getProperty().getId()));
execCommandStack(cc);
}
}
Aggregations