Search in sources :

Example 6 with BusinessAssignment

use of org.talend.designer.business.model.business.BusinessAssignment in project tdi-studio-se by Talend.

the class AssignmentPropertySection method executeDeleteCommand.

private void executeDeleteCommand(IStructuredSelection structuredSelection) {
    UnassignTalendItemsFromBusinessAssignmentCommand command = new UnassignTalendItemsFromBusinessAssignmentCommand(getEditingDomain(), true);
    for (Iterator iter = structuredSelection.iterator(); iter.hasNext(); ) {
        Object object = (Object) iter.next();
        if (object instanceof BusinessAssignment) {
            BusinessAssignment businessAssignment = (BusinessAssignment) object;
            command.addBusinessAssignment(businessAssignment);
        }
    }
    List<ICommand> commands = new ArrayList<ICommand>();
    commands.add(command);
    //$NON-NLS-1$
    executeAsCompositeCommand(Messages.getString("AssignmentPropertySection.DeleteAssignment"), commands);
}
Also used : BusinessAssignment(org.talend.designer.business.model.business.BusinessAssignment) UnassignTalendItemsFromBusinessAssignmentCommand(org.talend.designer.business.diagram.custom.commands.UnassignTalendItemsFromBusinessAssignmentCommand) ICommand(org.eclipse.gmf.runtime.common.core.command.ICommand) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Example 7 with BusinessAssignment

use of org.talend.designer.business.model.business.BusinessAssignment in project tdi-studio-se by Talend.

the class TalendSVGIDGenerator method generateID.

@Override
public String generateID(String prefix) {
    Integer maxId = (Integer) prefixMap.get(prefix);
    if (maxId == null) {
        maxId = new Integer(0);
        prefixMap.put(prefix, maxId);
    }
    maxId = new Integer(maxId.intValue() + 1);
    prefixMap.put(prefix, maxId);
    if (svgObject != null && maxId - 1 < svgObject.size() && prefix.equals(SVGSyntax.ID_PREFIX_CLIP_PATH)) {
        if (svgObject.get(maxId - 1) != null) {
            Object obj = svgObject.get(maxId - 1);
            if (obj instanceof BusinessItemShape) {
                BusinessItemShape item = (BusinessItemShape) obj;
                String id = "";
                for (Object assign : item.getAssignments()) {
                    if (assign instanceof BusinessAssignment) {
                        BusinessAssignment assignment = (BusinessAssignment) assign;
                        id = id + assignment.getTalendItem().getLabel() + ";";
                    }
                }
                if (id != "") {
                    id = id.substring(0, id.length() - 1);
                    return "businessItem." + businessModels.indexOf(obj);
                }
            }
        }
    }
    return prefix + maxId;
}
Also used : BusinessItemShape(org.talend.designer.business.model.business.BusinessItemShape) BusinessAssignment(org.talend.designer.business.model.business.BusinessAssignment)

Example 8 with BusinessAssignment

use of org.talend.designer.business.model.business.BusinessAssignment in project tdi-studio-se by Talend.

the class BusinessAssignmentComposite method getItemPropertyDescriptor.

private IItemPropertyDescriptor getItemPropertyDescriptor() {
    // PTODO mhelleboid find another way to itempropertysource without an eobject
    BusinessAssignment sampleBusinessAssignment = BusinessFactory.eINSTANCE.createBusinessAssignment();
    EStructuralFeature businessAssignment_Comment = BusinessPackage.eINSTANCE.getBusinessAssignment_Comment();
    IItemPropertySource itemPropertySource = EmfPropertyHelper.getItemPropertySource(adapterFactory, sampleBusinessAssignment);
    return EmfPropertyHelper.getItemPropertyDescriptor(itemPropertySource, sampleBusinessAssignment, businessAssignment_Comment);
}
Also used : BusinessAssignment(org.talend.designer.business.model.business.BusinessAssignment) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) IItemPropertySource(org.eclipse.emf.edit.provider.IItemPropertySource)

Example 9 with BusinessAssignment

use of org.talend.designer.business.model.business.BusinessAssignment in project tdi-studio-se by Talend.

the class ClipboardActionHandler method saveCut.

private void saveCut(ISelection object) {
    cutItemIds = new HashMap();
    if (object instanceof IStructuredSelection) {
        for (Object obj : ((IStructuredSelection) object).toList()) {
            if (obj instanceof AbstractEditPart) {
                AbstractEditPart editPart = (AbstractEditPart) obj;
                EObject element = ((View) editPart.getModel()).getElement();
                if (element instanceof BusinessItem) {
                    BusinessItem businessItem = (BusinessItem) element;
                    List assignments = new ArrayList();
                    for (Object assignment : businessItem.getAssignments()) {
                        BusinessAssignment ba = (BusinessAssignment) assignment;
                        TalendItem item = ba.getTalendItem();
                        if (item != null) {
                            assignments.add(item.getId());
                        }
                    }
                    cutItemIds.put(businessItem, assignments);
                }
            }
        }
    }
}
Also used : BusinessAssignment(org.talend.designer.business.model.business.BusinessAssignment) HashMap(java.util.HashMap) AbstractEditPart(org.eclipse.gef.editparts.AbstractEditPart) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) List(java.util.List) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TalendItem(org.talend.designer.business.model.business.TalendItem) View(org.eclipse.gmf.runtime.notation.View) BusinessItem(org.talend.designer.business.model.business.BusinessItem)

Example 10 with BusinessAssignment

use of org.talend.designer.business.model.business.BusinessAssignment in project tdi-studio-se by Talend.

the class DuplicateAnythingCommand method doExecuteWithResult.

@Override
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
    // Remove elements whose container is getting copied.
    ClipboardSupportUtil.getCopyElements(getObjectsToBeDuplicated());
    // Perform the copy and update the references.
    EcoreUtil.Copier copier = new EcoreUtil.Copier();
    copier.copyAll(getObjectsToBeDuplicated());
    copier.copyReferences();
    // Update the map with all elements duplicated.
    getAllDuplicatedObjectsMap().putAll(copier);
    Map targetAndSource = new HashMap();
    // Add the duplicates to the original's container.
    for (Iterator i = getObjectsToBeDuplicated().iterator(); i.hasNext(); ) {
        EObject original = (EObject) i.next();
        EObject duplicate = (EObject) copier.get(original);
        targetAndSource.put(duplicate, original);
        EReference reference = original.eContainmentFeature();
        if (reference != null && FeatureMapUtil.isMany(original.eContainer(), reference) && ClipboardSupportUtil.isOkToAppendEObjectAt(original.eContainer(), reference, duplicate)) {
            ClipboardSupportUtil.appendEObjectAt(original.eContainer(), reference, duplicate);
        }
    }
    for (Object obj : targetAndSource.keySet()) {
        if (obj instanceof BusinessItem) {
            BusinessItem item = (BusinessItem) obj;
            Object sourceObject = targetAndSource.get(item);
            if (sourceObject instanceof BusinessItem) {
                BusinessItem sourceItem = (BusinessItem) sourceObject;
                List targetAssignments = item.getAssignments();
                List sourceAssignments = sourceItem.getAssignments();
                for (int i = 0; i < targetAssignments.size() && i < sourceAssignments.size(); i++) {
                    BusinessAssignment targetAssign = (BusinessAssignment) targetAssignments.get(i);
                    targetAssign.setComment(((BusinessAssignment) sourceAssignments.get(i)).getComment());
                    targetAssign.setTalendItem(((BusinessAssignment) sourceAssignments.get(i)).getTalendItem());
                }
            }
        }
    }
    return null;
}
Also used : BusinessAssignment(org.talend.designer.business.model.business.BusinessAssignment) HashMap(java.util.HashMap) EObject(org.eclipse.emf.ecore.EObject) Iterator(java.util.Iterator) EObject(org.eclipse.emf.ecore.EObject) List(java.util.List) EcoreUtil(org.eclipse.emf.ecore.util.EcoreUtil) HashMap(java.util.HashMap) Map(java.util.Map) EReference(org.eclipse.emf.ecore.EReference) BusinessItem(org.talend.designer.business.model.business.BusinessItem)

Aggregations

BusinessAssignment (org.talend.designer.business.model.business.BusinessAssignment)16 List (java.util.List)9 TalendItem (org.talend.designer.business.model.business.TalendItem)8 ArrayList (java.util.ArrayList)6 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)6 BusinessItem (org.talend.designer.business.model.business.BusinessItem)6 Routine (org.talend.designer.business.model.business.Routine)5 SQLPattern (org.talend.designer.business.model.business.SQLPattern)5 Iterator (java.util.Iterator)4 EObject (org.eclipse.emf.ecore.EObject)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 PersistenceException (org.talend.commons.exception.PersistenceException)4 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)4 SAPFunctionUnit (org.talend.core.model.metadata.builder.connection.SAPFunctionUnit)4 View (org.eclipse.gmf.runtime.notation.View)3 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3 Query (org.talend.core.model.metadata.builder.connection.Query)3 RepositoryNode (org.talend.repository.model.RepositoryNode)3 HashMap (java.util.HashMap)2 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)2