use of org.talend.dataquality.properties.TDQIndicatorDefinitionItem 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;
}
use of org.talend.dataquality.properties.TDQIndicatorDefinitionItem in project tdq-studio-se by Talend.
the class UDIUtils method checkUDIDependency.
public static ReturnCode checkUDIDependency(IndicatorDefinition definition, File delFile) {
ReturnCode result = new ReturnCode(true);
IPath filePath = new Path(delFile.getPath());
if (!ResourceManager.getUDIJarFolder().getLocation().isPrefixOf(filePath)) {
// filePath.makeRelativeTo(ResourceManager.getRootFolderLocation()))) {
return result;
}
for (IRepositoryNode indiDefNode : RepositoryNodeHelper.getUdisRepositoryNodes(true)) {
IndicatorDefinition indiDef = null;
Item item = indiDefNode.getObject().getProperty().getItem();
if (item instanceof TDQIndicatorDefinitionItem) {
indiDef = ((TDQIndicatorDefinitionItem) item).getIndicatorDefinition();
} else {
continue;
}
// when it is itself, don't use this check.
if (indiDef == definition) {
continue;
}
// ADD end
TaggedValue tv = TaggedValueHelper.getTaggedValue(TaggedValueHelper.JAR_FILE_PATH, indiDef.getTaggedValue());
if (tv == null) {
continue;
}
// $NON-NLS-1$
String[] strArray = tv.getValue().split("\\|\\|");
int index = Arrays.binarySearch(strArray, filePath.lastSegment());
if (index >= 0) {
// $NON-NLS-1$ //$NON-NLS-2$
result.setMessage("The jar file(" + strArray[index] + ") has in use by UDI for " + indiDef.getName());
result.setOk(false);
return result;
}
}
return result;
}
use of org.talend.dataquality.properties.TDQIndicatorDefinitionItem 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;
}
use of org.talend.dataquality.properties.TDQIndicatorDefinitionItem in project tdq-studio-se by Talend.
the class IndicatorDefinitionWriter method save.
@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 Indicator Definition item") {
@Override
protected void run() throws LoginException, PersistenceException {
TDQIndicatorDefinitionItem indicatorItem = (TDQIndicatorDefinitionItem) item;
IndicatorDefinition indiDefinition = indicatorItem.getIndicatorDefinition();
String oldName = indiDefinition.getLabel();
indiDefinition.setLabel(indiDefinition.getName());
// MOD yyi 2012-02-07 TDQ-4621:Update dependencies when careDependency is true.
if (careDependency) {
saveWithDependencies(indicatorItem, indiDefinition);
} else {
saveWithoutDependencies(indicatorItem, indiDefinition);
}
updateDependencies(indiDefinition);
checkNameUpdate(oldName, item);
}
};
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;
}
use of org.talend.dataquality.properties.TDQIndicatorDefinitionItem in project tdq-studio-se by Talend.
the class DeleteResourceProvider method isSystemIndicator.
private boolean isSystemIndicator(RepositoryNode node) {
switch(node.getType()) {
case TDQ_REPOSITORY_ELEMENT:
case REPOSITORY_ELEMENT:
if (node.getObject() != null) {
Item item = node.getObject().getProperty().getItem();
IFolder folder = WorkbenchUtils.getFolder(node);
return item instanceof TDQIndicatorDefinitionItem && ResourceService.isSubFolder(ResourceManager.getSystemIndicatorFolder(), folder);
}
default:
}
return false;
}
Aggregations