Search in sources :

Example 1 with TDQMatchRuleItem

use of org.talend.dataquality.properties.TDQMatchRuleItem in project tmdm-studio-se by Talend.

the class RepositoryResourceUtil method getItemFile.

public static IFile getItemFile(IRepositoryViewObject viewObj) {
    Item item = viewObj.getProperty().getItem();
    // $NON-NLS-1$
    String extName = "item";
    if (item instanceof TDQMatchRuleItem) {
        // $NON-NLS-1$
        extName = "rules";
    }
    return findReferenceFile(viewObj.getRepositoryObjectType(), item, extName);
}
Also used : ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) TDQMatchRuleItem(org.talend.dataquality.properties.TDQMatchRuleItem) WorkspaceRootItem(org.talend.mdm.repository.model.mdmproperties.WorkspaceRootItem) Item(org.talend.core.model.properties.Item) FolderItem(org.talend.core.model.properties.FolderItem) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) TDQMatchRuleItem(org.talend.dataquality.properties.TDQMatchRuleItem)

Example 2 with TDQMatchRuleItem

use of org.talend.dataquality.properties.TDQMatchRuleItem in project tdq-studio-se by Talend.

the class PropertyHelper method getModelElement.

/**
 * DOC bZhou Comment method "getModelElement".
 *
 * Get model element from property recognized by current system.
 *
 * @param property
 * @return
 */
public static ModelElement getModelElement(Property property) {
    Item item = property.getItem();
    assert item != null;
    ModelElement element = (ModelElement) new org.talend.core.model.properties.util.PropertiesSwitch() {

        @Override
        public Object caseDatabaseConnectionItem(DatabaseConnectionItem object) {
            return object.getConnection();
        }

        @Override
        public Object caseMDMConnectionItem(MDMConnectionItem object) {
            return object.getConnection();
        }

        @Override
        public Object caseDelimitedFileConnectionItem(DelimitedFileConnectionItem object) {
            return object.getConnection();
        }
    }.doSwitch(item);
    if (element == null) {
        element = new org.talend.dataquality.properties.util.PropertiesSwitch<ModelElement>() {

            @Override
            public ModelElement caseTDQReportItem(TDQReportItem object) {
                return object.getReport();
            }

            @Override
            public ModelElement caseTDQAnalysisItem(TDQAnalysisItem object) {
                return object.getAnalysis();
            }

            @Override
            public ModelElement caseTDQBusinessRuleItem(TDQBusinessRuleItem object) {
                return object.getDqrule();
            }

            /*
                 * (non-Javadoc)
                 * 
                 * @see
                 * org.talend.dataquality.properties.util.PropertiesSwitch#caseTDQMatchRuleItem(org.talend.dataquality
                 * .properties.TDQMatchRuleItem)
                 */
            @Override
            public ModelElement caseTDQMatchRuleItem(TDQMatchRuleItem object) {
                return object.getMatchRule();
            }

            @Override
            public ModelElement caseTDQIndicatorDefinitionItem(TDQIndicatorDefinitionItem object) {
                return object.getIndicatorDefinition();
            }

            @Override
            public ModelElement caseTDQPatternItem(TDQPatternItem object) {
                return object.getPattern();
            }
        }.doSwitch(item);
    }
    return element;
}
Also used : TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) TDQMatchRuleItem(org.talend.dataquality.properties.TDQMatchRuleItem) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) TDQPatternItem(org.talend.dataquality.properties.TDQPatternItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) DelimitedFileConnectionItem(org.talend.core.model.properties.DelimitedFileConnectionItem) Item(org.talend.core.model.properties.Item) FolderItem(org.talend.core.model.properties.FolderItem) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) TDQItem(org.talend.core.model.properties.TDQItem) TDQPatternItem(org.talend.dataquality.properties.TDQPatternItem) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) TDQMatchRuleItem(org.talend.dataquality.properties.TDQMatchRuleItem) TDQBusinessRuleItem(org.talend.dataquality.properties.TDQBusinessRuleItem) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) TDQBusinessRuleItem(org.talend.dataquality.properties.TDQBusinessRuleItem) DelimitedFileConnectionItem(org.talend.core.model.properties.DelimitedFileConnectionItem) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Example 3 with TDQMatchRuleItem

use of org.talend.dataquality.properties.TDQMatchRuleItem in project tdq-studio-se by Talend.

the class AbstractWizard method performFinish.

@Override
public boolean performFinish() {
    // wizard. TODO: consider other better solution.
    if (isDoingPerformFinish) {
        return true;
    }
    isDoingPerformFinish = true;
    // MOD mzhao feature 15750 Use repository object represent ModelElement.
    modelElement = initCWMResourceBuilder();
    if (modelElement != null) {
        fillMetadataToCWMResource(modelElement);
        // Save the repository objects.
        TypedReturnCode<Object> csResult = createAndSaveCWMFile(modelElement);
        if (csResult.isOk()) {
            Object savedObj = csResult.getObject();
            if (savedObj instanceof Item) {
                if (!RepositoryNodeHelper.isOpenDQCommonViewer() && savedObj instanceof TDQMatchRuleItem) {
                    openEditor((TDQMatchRuleItem) savedObj);
                } else {
                    RepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(((Item) savedObj).getProperty());
                    openEditor(recursiveFind);
                }
            }
            CorePlugin.getDefault().refresh(modelElement);
            isDoingPerformFinish = false;
            return true;
        } else {
            MessageUI.openError(csResult.getMessage());
        }
    }
    isDoingPerformFinish = false;
    return false;
}
Also used : ConnectionItem(org.talend.core.model.properties.ConnectionItem) TDQMatchRuleItem(org.talend.dataquality.properties.TDQMatchRuleItem) Item(org.talend.core.model.properties.Item) TDQMatchRuleItem(org.talend.dataquality.properties.TDQMatchRuleItem) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 4 with TDQMatchRuleItem

use of org.talend.dataquality.properties.TDQMatchRuleItem in project tdq-studio-se by Talend.

the class AElementPersistance method createItem.

/**
 * DOC bZhou Comment method "createItem".
 *
 * @param element
 * @return
 */
public Item createItem(ModelElement element) {
    Item item = null;
    // MOD mzhao feature 13114, 2010-05-19 distinguish tdq items.
    if (ModelElementIdentifier.isAnalysis(element)) {
        item = PropertiesFactory.eINSTANCE.createTDQAnalysisItem();
        ((TDQAnalysisItem) item).setAnalysis((Analysis) element);
    } else if (ModelElementIdentifier.isDQRule(element)) {
        item = PropertiesFactory.eINSTANCE.createTDQBusinessRuleItem();
        ((TDQBusinessRuleItem) item).setDqrule((DQRule) element);
    } else if (ModelElementIdentifier.isDataProvider(element)) {
        if (element instanceof DatabaseConnection) {
            item = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createDatabaseConnectionItem();
            ((ConnectionItem) item).setConnection((DatabaseConnection) element);
        }
        ((ConnectionItem) item).setConnection((Connection) element);
    } else if (ModelElementIdentifier.isMatchRule(element)) {
        // this Condition must before the IndicatorDefinition one because MatchRule instance of it.
        item = PropertiesFactory.eINSTANCE.createTDQMatchRuleItem();
        ((TDQMatchRuleItem) item).setMatchRule((MatchRuleDefinition) element);
    } else if (ModelElementIdentifier.isID(element)) {
        item = PropertiesFactory.eINSTANCE.createTDQIndicatorDefinitionItem();
        ((TDQIndicatorDefinitionItem) item).setIndicatorDefinition((IndicatorDefinition) element);
    } else if (ModelElementIdentifier.isPattern(element)) {
        item = PropertiesFactory.eINSTANCE.createTDQPatternItem();
        ((TDQPatternItem) item).setPattern((Pattern) element);
    } else if (ModelElementIdentifier.isReport(element)) {
        item = PropertiesFactory.eINSTANCE.createTDQReportItem();
        ((TDQReportItem) item).setReport((Report) element);
    } else {
        item = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createTDQItem();
    }
    ItemState itemState = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
    itemState.setDeleted(false);
    item.setState(itemState);
    if (item instanceof TDQItem) {
        setTDQItemFileName(element, item);
    }
    Resource eResource = element.eResource();
    if (eResource != null) {
        URI uri = eResource.getURI();
        if (uri.isPlatform()) {
            IPath elementPath = new Path(uri.toPlatformString(true)).removeLastSegments(1);
            IPath typedPath = ResourceManager.getRootProject().getFullPath().append(PropertyHelper.getItemTypedPath(item));
            IPath statePath = elementPath.makeRelativeTo(typedPath);
            itemState.setPath(statePath.toString());
        }
    }
    return item;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) Pattern(org.talend.dataquality.domain.pattern.Pattern) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) IPath(org.eclipse.core.runtime.IPath) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Resource(org.eclipse.emf.ecore.resource.Resource) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) URI(org.eclipse.emf.common.util.URI) DQRule(org.talend.dataquality.rules.DQRule) Item(org.talend.core.model.properties.Item) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) TDQItem(org.talend.core.model.properties.TDQItem) TDQPatternItem(org.talend.dataquality.properties.TDQPatternItem) TDQMatchRuleItem(org.talend.dataquality.properties.TDQMatchRuleItem) TDQBusinessRuleItem(org.talend.dataquality.properties.TDQBusinessRuleItem) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) ItemState(org.talend.core.model.properties.ItemState) TDQItem(org.talend.core.model.properties.TDQItem) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Example 5 with TDQMatchRuleItem

use of org.talend.dataquality.properties.TDQMatchRuleItem in project tdq-studio-se by Talend.

the class MatchRuleDefinitionWriter method save.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dq.writer.AElementPersistance#save(org.talend.core.model.properties.Item, boolean)
     */
@Override
public ReturnCode save(final Item item, final boolean careDependency) {
    ReturnCode rc = new ReturnCode();
    RepositoryWorkUnit<Object> repositoryWorkUnit = new // $NON-NLS-1$
    RepositoryWorkUnit<Object>(// $NON-NLS-1$
    "save MatchRule Definition item") {

        @Override
        protected void run() throws LoginException, PersistenceException {
            TDQMatchRuleItem matchRuleItem = (TDQMatchRuleItem) item;
            MatchRuleDefinition matchRuleDefinition = matchRuleItem.getMatchRule();
            if (careDependency) {
                saveWithDependencies(matchRuleItem, matchRuleDefinition);
            } else {
                saveWithoutDependencies(matchRuleItem, matchRuleDefinition);
            }
        }
    };
    repositoryWorkUnit.setAvoidUnloadResources(true);
    ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(repositoryWorkUnit);
    try {
        repositoryWorkUnit.throwPersistenceExceptionIfAny();
    } catch (PersistenceException e) {
        log.error(e, e);
        rc.setOk(Boolean.FALSE);
        rc.setMessage(e.getMessage());
    }
    return rc;
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) TDQMatchRuleItem(org.talend.dataquality.properties.TDQMatchRuleItem) PersistenceException(org.talend.commons.exception.PersistenceException) RepositoryWorkUnit(org.talend.repository.RepositoryWorkUnit) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition)

Aggregations

TDQMatchRuleItem (org.talend.dataquality.properties.TDQMatchRuleItem)8 Item (org.talend.core.model.properties.Item)5 MatchRuleDefinition (org.talend.dataquality.rules.MatchRuleDefinition)4 TDQAnalysisItem (org.talend.dataquality.properties.TDQAnalysisItem)3 TDQBusinessRuleItem (org.talend.dataquality.properties.TDQBusinessRuleItem)3 TDQIndicatorDefinitionItem (org.talend.dataquality.properties.TDQIndicatorDefinitionItem)3 TDQPatternItem (org.talend.dataquality.properties.TDQPatternItem)3 TDQReportItem (org.talend.dataquality.properties.TDQReportItem)3 Resource (org.eclipse.emf.ecore.resource.Resource)2 PersistenceException (org.talend.commons.exception.PersistenceException)2 ConnectionItem (org.talend.core.model.properties.ConnectionItem)2 FolderItem (org.talend.core.model.properties.FolderItem)2 TDQItem (org.talend.core.model.properties.TDQItem)2 Pattern (org.talend.dataquality.domain.pattern.Pattern)2 DQRule (org.talend.dataquality.rules.DQRule)2 ReturnCode (org.talend.utils.sugars.ReturnCode)2 IResource (org.eclipse.core.resources.IResource)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1 URI (org.eclipse.emf.common.util.URI)1