use of orgomg.cwm.foundation.softwaredeployment.DeployedComponent in project tdq-studio-se by Talend.
the class SoftwareSystemManager method cleanSoftWareSystem.
/**
* remove the softWareSystem which have relation about dataprovider and any softWareSystem which don't contain any
* one.
*
* @param dataProvider
* @return
* @deprecated
*/
@Deprecated
public boolean cleanSoftWareSystem(Connection dataProvider) {
if (dataProvider == null) {
return false;
}
Resource softwareSystemResource = EMFSharedResources.getInstance().getSoftwareDeploymentResource();
if (WorkspaceUtils.getModelElementResource(softwareSystemResource.getURI()).exists()) {
softwareSystemResource = EMFSharedResources.getInstance().reloadsoftwareDeploymentResource();
}
if (softwareSystemResource != null) {
List<EObject> softwareSystems = softwareSystemResource.getContents();
// Loop the software system from .softwaresystem.softwaredeployment file.
List<EObject> needToRemoves = new ArrayList<EObject>();
for (EObject softwareSystem : softwareSystems) {
if (softwareSystem instanceof TdSoftwareSystem) {
List<ModelElement> ownedELements = ((TdSoftwareSystem) softwareSystem).getOwnedElement();
// Loop owned element.
for (ModelElement me : ownedELements) {
if (me == null || !(me instanceof Component)) {
continue;
}
List<DeployedComponent> deployComponents = ((Component) me).getDeployment();
if (deployComponents.size() > 0) {
if (ResourceHelper.areSame(deployComponents.get(0), dataProvider)) {
needToRemoves.add(softwareSystem);
break;
}
} else {
needToRemoves.add(softwareSystem);
}
}
if (ownedELements.size() <= 0) {
needToRemoves.add(softwareSystem);
}
}
}
if (needToRemoves.size() > 0) {
softwareSystems.removeAll(needToRemoves);
EMFSharedResources.getInstance().saveSoftwareDeploymentResource();
return true;
}
}
return false;
}
Aggregations