use of orgomg.cwm.objectmodel.core.Dependency in project tdq-studio-se by Talend.
the class ReorderingLibraryFoldersTask method moveItems.
private void moveItems(IFolder oldSubFolder, IFolder newSubfolder) throws CoreException {
if (!oldSubFolder.exists()) {
return;
}
for (IResource oldResource : oldSubFolder.members()) {
if (newSubfolder.getName().equals(oldResource.getName())) {
continue;
}
// cannot simply copy EMF files: need to keep the links between files when moving them. See bug 9461
if (oldResource instanceof IFolder) {
IFolder oldFolder = (IFolder) oldResource;
IFolder newFolder = DQStructureManager.getInstance().createNewFolder(newSubfolder, oldFolder.getName());
moveItems(oldFolder, newFolder);
// delete folder
oldFolder.delete(true, null);
}
if (oldResource instanceof IFile) {
IFile file = (IFile) oldResource;
final ModelElement eltFromLibraryFolder = getModelElement(file);
final EList<Dependency> supplierDependency = eltFromLibraryFolder.getSupplierDependency();
if (supplierDependency.isEmpty()) {
// simple copy of file is enough
oldResource.copy(newSubfolder.getFolder(oldResource.getName()).getFullPath(), true, null);
} else {
// handle dependent analyses
List<Analysis> analyses = new ArrayList<Analysis>();
for (Dependency dependency : supplierDependency) {
URI newUri = URI.createPlatformResourceURI(newSubfolder.getFullPath().toOSString(), true);
// move pattern
EMFUtil.changeUri(eltFromLibraryFolder.eResource(), newUri);
final EList<ModelElement> clientAnalyses = dependency.getClient();
for (ModelElement modelElement : clientAnalyses) {
Analysis analysis = DataqualitySwitchHelper.ANALYSIS_SWITCH.doSwitch(modelElement);
if (analysis != null) {
analyses.add(analysis);
}
}
}
// clean the dependencies that do not refer to an existing object.
for (Analysis analysis : analyses) {
final EList<Dependency> clientDependency = analysis.getClientDependency();
List<Dependency> newClientDeps = new ArrayList<Dependency>();
for (Dependency dependency : clientDependency) {
if (!dependency.eIsProxy()) {
newClientDeps.add(dependency);
}
}
clientDependency.clear();
clientDependency.addAll(newClientDeps);
AnaResourceFileHelper.getInstance().save(analysis);
}
}
remove(file);
}
}
}
use of orgomg.cwm.objectmodel.core.Dependency in project tdq-studio-se by Talend.
the class TDQResourceChangeHandler method updateDependeciesWhenVersionChange.
@Override
public void updateDependeciesWhenVersionChange(ConnectionItem connItem, String oldVersion, String newVersion) {
Connection connection = connItem.getConnection();
if (connection != null) {
EList<Dependency> supplierDependencies = connection.getSupplierDependency();
if (supplierDependencies != null && !supplierDependencies.isEmpty()) {
Dependency[] arraySupplierDeps = supplierDependencies.toArray(new Dependency[supplierDependencies.size()]);
for (Dependency supplierDep : arraySupplierDeps) {
EList<ModelElement> clients = supplierDep.getClient();
if (clients != null && !clients.isEmpty()) {
ModelElement[] arrayClients = clients.toArray(new ModelElement[clients.size()]);
for (ModelElement client : arrayClients) {
if (client instanceof Analysis) {
IFile clientFile = AnaResourceFileHelper.findCorrespondingFile(client);
if (clientFile != null) {
File file = WorkspaceUtils.ifileToFile(clientFile);
if (file != null) {
replaceVersionInfo(connection.getName(), file, oldVersion, newVersion);
reloadFile(file);
}
}
}
}
}
}
ResourceService.refreshStructure();
WorkbenchUtils.refreshAnalysesNode();
WorkbenchUtils.refreshMetadataNode();
}
}
}
use of orgomg.cwm.objectmodel.core.Dependency in project tdq-studio-se by Talend.
the class DeleteModelElementConfirmDialog method addDenpendencyElements.
static void addDenpendencyElements(ModelElement[] children) {
for (ModelElement element : children) {
EList<Dependency> supplierDependencies = element.getSupplierDependency();
ImpactNode impactNode;
for (Dependency dependency : supplierDependencies) {
EList<ModelElement> clients = dependency.getClient();
for (ModelElement client : clients) {
// ~
if (!client.eIsProxy()) {
impactNode = new ImpactNode(client);
int index = impactNodes.indexOf(impactNode);
if (index == -1) {
impactNode.addRequireModelElement(element);
impactNodes.add(impactNode);
} else {
ImpactNode existNode = impactNodes.get(index);
existNode.addRequireModelElement(element);
}
}
}
}
}
}
use of orgomg.cwm.objectmodel.core.Dependency in project tdq-studio-se by Talend.
the class EObjectHelper method getDependencySuppliers.
public static List<ModelElement> getDependencySuppliers(IFile file) {
ModelElement findElement = getModelElement(file);
EList<Dependency> clientDependencys = findElement.getClientDependency();
// locate resource of each Dependency object
List<ModelElement> supplierList = new ArrayList<ModelElement>();
for (Dependency dependency : clientDependencys) {
EList<ModelElement> supplier = dependency.getSupplier();
if (supplier != null) {
supplierList.addAll(supplier);
}
}
return supplierList;
}
use of orgomg.cwm.objectmodel.core.Dependency in project tdq-studio-se by Talend.
the class EObjectHelper method getDependencyClients.
public static List<ModelElement> getDependencyClients(ModelElement modelElement) {
if (modelElement == null) {
return new ArrayList<ModelElement>();
}
EList<Dependency> clientDependencys = modelElement.getSupplierDependency();
// locate resource of each Dependency object
List<ModelElement> supplierList = new ArrayList<ModelElement>();
for (Dependency dependency : clientDependencys) {
EList<ModelElement> clients = dependency.getClient();
if (clients != null) {
for (ModelElement client : clients) {
if (!client.eIsProxy()) {
supplierList.add(client);
}
}
}
}
return supplierList;
}
Aggregations