use of org.talend.designer.business.diagram.custom.util.RepositoryHelper in project tdi-studio-se by Talend.
the class GmfPastCommand method cloneAssignmentForModel.
private void cloneAssignmentForModel(List<BusinessItem> nodes, List pChildren) {
if (nodes == null || pChildren == null) {
return;
}
int i = nodes.size();
for (BusinessItem businessItem : getSortedBusinessItems(nodes)) {
BusinessItem newItem = (BusinessItem) getEObject(businessItem);
if (!addNew) {
newItem.setBusinessProcess(businessItem.getBusinessProcess());
}
newItem.setHAlignment(businessItem.getHAlignment());
newItem.setName(businessItem.getName());
newItem.setVAlignment(businessItem.getVAlignment());
List assignments = new ArrayList();
boolean execute = false;
int n = 0;
for (Object object : businessItem.getAssignments()) {
BusinessAssignment older = (BusinessAssignment) object;
BusinessAssignment newAssignment = (BusinessAssignment) getEObject(older);
newAssignment.setBusinessItem(newItem);
newAssignment.setComment(older.getComment());
if (!addNew) {
newAssignment.setTalendItem(older.getTalendItem());
} else {
TalendItem item = older.getTalendItem();
String talendId = null;
if (item != null) {
talendId = item.getId();
} else {
List idList = (List) itemIds.get(businessItem);
if (n < idList.size()) {
talendId = (String) idList.get(n);
}
n++;
}
RepositoryNode node = null;
if (talendId.split(" - ").length == 1) {
//$NON-NLS-1$
node = RepositoryNodeUtilities.getRepositoryNode(talendId);
} else {
node = RepositoryNodeUtilities.getMetadataTableFromConnection(talendId);
if (node == null) {
node = RepositoryNodeUtilities.getQueryFromConnection(talendId);
}
}
RepositoryHelper repositoryHelper = new RepositoryHelper();
Repository repository = process.getLocalRepositoryCopy();
if (repository == null) {
repository = repositoryHelper.createLocalRepositoryCopy(process);
}
TalendItem talendItem = repositoryHelper.createTalendItem(repository, node);
newAssignment.setTalendItem(talendItem);
}
assignments.add(newAssignment);
}
if (assignments.size() > 0) {
newItem.getAssignments().addAll(assignments);
}
if (i <= pChildren.size()) {
View node = (View) pChildren.get(pChildren.size() - i);
node.setElement(newItem);
i--;
}
if (addNew) {
this.process.getBusinessItems().add(newItem);
}
}
}
use of org.talend.designer.business.diagram.custom.util.RepositoryHelper in project tdi-studio-se by Talend.
the class CreateAssignmentCommand method doExecuteWithResult.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse
* .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
*/
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
// PTODO mhelleboid check if assignment already exist
RepositoryHelper repositoryHelper = new RepositoryHelper();
Repository repository = businessItem.getBusinessProcess().getLocalRepositoryCopy();
TalendItem talendItem = null;
if (repository == null) {
repository = repositoryHelper.createLocalRepositoryCopy(businessItem.getBusinessProcess());
}
for (Object item : getItems()) {
BusinessAssignment assignment = BusinessFactory.eINSTANCE.createBusinessAssignment();
talendItem = repositoryHelper.getTalendItem(repository, item);
if (talendItem == null) {
talendItem = repositoryHelper.createTalendItem(repository, item);
}
if (talendItem == null) {
//$NON-NLS-1$
return CommandResult.newErrorCommandResult(Messages.getString("CreateAssignmentCommand.CannotAssign"));
}
assignment.setBusinessItem(businessItem);
assignment.setTalendItem(talendItem);
}
return CommandResult.newOKCommandResult();
}
Aggregations