Search in sources :

Example 1 with ValidationRulesConnectionItem

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;
}
Also used : ValidationRulesConnection(org.talend.core.model.metadata.builder.connection.ValidationRulesConnection) HL7ConnectionItem(org.talend.core.model.properties.HL7ConnectionItem) WSDLSchemaConnectionItem(org.talend.core.model.properties.WSDLSchemaConnectionItem) Item(org.talend.core.model.properties.Item) ValidationRulesConnectionItem(org.talend.core.model.properties.ValidationRulesConnectionItem) XmlFileConnectionItem(org.talend.core.model.properties.XmlFileConnectionItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) ValidationRulesConnectionItem(org.talend.core.model.properties.ValidationRulesConnectionItem) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 2 with ValidationRulesConnectionItem

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);
    }
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) INode(org.talend.core.model.process.INode) RepositoryNode(org.talend.repository.model.RepositoryNode) HL7FileNode(org.talend.core.model.metadata.builder.connection.HL7FileNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) XMLFileNode(org.talend.core.model.metadata.builder.connection.XMLFileNode) MapperExternalNode(org.talend.core.model.process.node.MapperExternalNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ValidationRulesConnectionItem(org.talend.core.model.properties.ValidationRulesConnectionItem) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Aggregations

ValidationRulesConnectionItem (org.talend.core.model.properties.ValidationRulesConnectionItem)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 ArrayList (java.util.ArrayList)1 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 HL7FileNode (org.talend.core.model.metadata.builder.connection.HL7FileNode)1 ValidationRulesConnection (org.talend.core.model.metadata.builder.connection.ValidationRulesConnection)1 XMLFileNode (org.talend.core.model.metadata.builder.connection.XMLFileNode)1 IExternalNode (org.talend.core.model.process.IExternalNode)1 INode (org.talend.core.model.process.INode)1 MapperExternalNode (org.talend.core.model.process.node.MapperExternalNode)1 HL7ConnectionItem (org.talend.core.model.properties.HL7ConnectionItem)1 Item (org.talend.core.model.properties.Item)1 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)1 WSDLSchemaConnectionItem (org.talend.core.model.properties.WSDLSchemaConnectionItem)1 XmlFileConnectionItem (org.talend.core.model.properties.XmlFileConnectionItem)1 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)1 NodeContainerPart (org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart)1 Node (org.talend.designer.core.ui.editor.nodes.Node)1 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)1