use of org.talend.utils.sugars.ReturnCode in project tdq-studio-se by Talend.
the class AElementPersistance method save.
/**
* DOC bZhou Comment method "save".
*
* Save a model element and update the related property.
*
* @param element
* @param withProperty
* @return
*/
public ReturnCode save(ModelElement element, boolean withProperty) {
ReturnCode rc = new ReturnCode();
addDependencies(element);
addResourceContent(element);
rc.setOk(util.saveResource(element.eResource()));
if (withProperty) {
updateProperty(element);
}
if (rc.isOk()) {
// $NON-NLS-1$ //$NON-NLS-2$
rc.setMessage("save " + element.getName() + " is OK!");
if (withProperty) {
notifyResourceChanges();
}
} else {
rc.setMessage(util.getLastErrorMessage());
}
return rc;
}
use of org.talend.utils.sugars.ReturnCode in project tdq-studio-se by Talend.
the class AnalysisWriter method removeDependencies.
/*
* (non-Javadoc)
*
* @see org.talend.dq.writer.AElementPersistance#removeDependencies(org.talend.core.model.properties.Item)
*/
@Override
protected ReturnCode removeDependencies(Item item) {
ReturnCode rc = new ReturnCode();
TDQAnalysisItem anaItem = (TDQAnalysisItem) item;
Analysis analysis = anaItem.getAnalysis();
List<Property> clintDependency = DependenciesHandler.getInstance().getClintDependency(anaItem.getProperty());
List<ModelElement> clientDepListByResultList = DependenciesHandler.getInstance().getClientDepListByResult(analysis);
for (Property currentClient : clintDependency) {
ModelElement modelElement = PropertyHelper.getModelElement(currentClient);
if (!clientDepListByResultList.contains(modelElement)) {
boolean isSuccess = DependenciesHandler.getInstance().removeDependenciesBetweenModel(analysis, modelElement);
if (isSuccess) {
try {
ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().saveResource(modelElement.eResource());
} catch (PersistenceException e) {
log.error(e, e);
rc.setOk(false);
rc.setMessage(e.getMessage());
}
} else {
rc.setOk(false);
rc.setMessage(// $NON-NLS-1$
Messages.getString(// $NON-NLS-1$
"AnalysisWriter.CanNotFindDependencyElement", // $NON-NLS-1$
analysis.getName(), modelElement.getName()));
}
}
}
return rc;
}
use of org.talend.utils.sugars.ReturnCode in project tdq-studio-se by Talend.
the class DataProviderWriter method create.
@Override
public ReturnCode create(ModelElement element, IFile file) {
ReturnCode rc = new ReturnCode();
IPath itemPath = file.getFullPath();
Property property = initProperty(element);
Item item = property.getItem();
try {
ProxyRepositoryFactory.getInstance().create(item, itemPath.removeFirstSegments(3).removeLastSegments(1));
} catch (PersistenceException e) {
log.error(e, e);
}
return rc;
}
use of org.talend.utils.sugars.ReturnCode 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.utils.sugars.ReturnCode in project tdq-studio-se by Talend.
the class WorkspaceResourceHelper method checkSourceFileSubFolderNodeOpening.
/**
* DOC xqliu Comment method "checkSourceFileSubFolderNodeOpening".
*
* @param node
* @return
*/
public static ReturnCode checkSourceFileSubFolderNodeOpening(RepositoryNode node) {
boolean opened = false;
// $NON-NLS-1$
String msg = "";
List<IRepositoryNode> children = node.getChildren();
for (IRepositoryNode iNode : children) {
if (iNode instanceof SourceFileRepNode || iNode instanceof JrxmlTempleteRepNode) {
ReturnCode rc = checkSourceFileNodeOpening((RepositoryNode) iNode);
if (rc.isOk()) {
opened = rc.isOk();
msg += rc.getMessage();
}
} else if (iNode instanceof SourceFileSubFolderNode || iNode instanceof JrxmlTempSubFolderNode) {
ReturnCode rc = checkSourceFileSubFolderNodeOpening((RepositoryNode) iNode);
if (rc.isOk()) {
opened = rc.isOk();
msg += rc.getMessage();
}
}
}
return new ReturnCode(msg, opened);
}
Aggregations