use of org.talend.designer.business.model.business.TalendItem in project tdi-studio-se by Talend.
the class BusinessAssignmentComposite method createRepositoryNode.
private RepositoryNode createRepositoryNode(BusinessAssignment businessAssignment) {
IRepositoryViewObject lastVersion;
try {
TalendItem item = businessAssignment.getTalendItem();
lastVersion = ProxyRepositoryFactory.getInstance().getLastVersion(item.getId());
if (lastVersion != null) {
ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(lastVersion.getProperty().getItem());
RepositoryNode repositoryNode = new RepositoryNode(lastVersion, RepositoryNodeUtilities.getParentRepositoryNodeFromSelection(lastVersion), ENodeType.REPOSITORY_ELEMENT);
repositoryNode.setProperties(EProperties.CONTENT_TYPE, itemType);
return repositoryNode;
} else if (item instanceof SQLPattern) {
IRepositoryViewObject object = getObjectFromSystem(item, ERepositoryObjectType.SQLPATTERNS);
if (object != null) {
RepositoryNode repositoryNode = new RepositoryNode(object, RepositoryNodeUtilities.getParentRepositoryNodeFromSelection(object), ENodeType.REPOSITORY_ELEMENT);
repositoryNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.SQLPATTERNS);
return repositoryNode;
}
} else if (item instanceof Routine) {
IRepositoryViewObject object = getObjectFromSystem(item, ERepositoryObjectType.ROUTINES);
if (object != null) {
RepositoryNode repositoryNode = new RepositoryNode(object, RepositoryNodeUtilities.getParentRepositoryNodeFromSelection(object), ENodeType.REPOSITORY_ELEMENT);
repositoryNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.ROUTINES);
return repositoryNode;
}
} else if (item instanceof TableMetadata) {
MetadataTable table = MetadataToolHelper.getMetadataTableFromRepository(item.getId());
if (table != null) {
return RepositoryNodeUtilities.getMetadataTableFromConnection(item.getId());
}
} else if (item instanceof Query) {
org.talend.core.model.metadata.builder.connection.Query query = MetadataToolHelper.getQueryFromRepository(item.getId());
if (query != null) {
return RepositoryNodeUtilities.getQueryFromConnection(item.getId());
}
} else if (item instanceof SAPFunction) {
SAPFunctionUnit function = MetadataToolHelper.getSAPFunctionFromRepository(item.getId());
if (function != null) {
return RepositoryNodeUtilities.getSAPFunctionFromConnection(item.getId());
}
}
} catch (PersistenceException e) {
}
return null;
}
use of org.talend.designer.business.model.business.TalendItem in project tdi-studio-se by Talend.
the class RepositoryFactoryProxyLabelProvider method getColumnImage.
@Override
public Image getColumnImage(Object object, int columnIndex) {
Image image = super.getColumnImage(object, columnIndex);
BusinessAssignment assignment = (BusinessAssignment) object;
try {
if (columnIndex == 0) {
IRepositoryViewObject lastVersion = getLastVersion(object);
if (lastVersion == null) {
MetadataTable table = MetadataToolHelper.getMetadataTableFromRepository(assignment.getTalendItem().getId());
if (table != null) {
return image;
}
Query query = MetadataToolHelper.getQueryFromRepository(assignment.getTalendItem().getId());
if (query != null) {
return image;
}
SAPFunctionUnit function = MetadataToolHelper.getSAPFunctionFromRepository(assignment.getTalendItem().getId());
if (function != null) {
return image;
}
TalendItem item = assignment.getTalendItem();
if (item instanceof SQLPattern) {
List<IRepositoryViewObject> list = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.SQLPATTERNS);
for (IRepositoryViewObject obj : list) {
if (item.getLabel().equals(obj.getLabel())) {
return image;
}
}
} else if (item instanceof Routine) {
List<IRepositoryViewObject> list = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.ROUTINES);
for (IRepositoryViewObject obj : list) {
if (item.getLabel().equals(obj.getLabel())) {
return image;
}
}
}
return new OverlayImage(image, ImageProvider.getImageDesc(ECoreImage.DELETED_OVERLAY), EPosition.BOTTOM_RIGHT).createImage();
} else if (isDeleted(lastVersion)) {
return new OverlayImage(image, ImageProvider.getImageDesc(ECoreImage.RECYCLE_BIN_OVERLAY), EPosition.BOTTOM_RIGHT).createImage();
}
}
} catch (PersistenceException e) {
// e.printStackTrace();
ExceptionHandler.process(e);
}
return image;
}
use of org.talend.designer.business.model.business.TalendItem in project tdi-studio-se by Talend.
the class RepositoryFactoryProxyLabelProvider method getColumnText.
@Override
public String getColumnText(Object object, int columnIndex) {
String columnText = super.getColumnText(object, columnIndex);
BusinessAssignment assignment = (BusinessAssignment) object;
IRepositoryViewObject lastVersion = getLastVersion(object);
try {
if (columnIndex == 0) {
if (lastVersion == null) {
MetadataTable table = MetadataToolHelper.getMetadataTableFromRepository(assignment.getTalendItem().getId());
if (table != null) {
if (SubItemHelper.isDeleted(table)) {
//$NON-NLS-1$
columnText += Messages.getString("RepositoryFactoryProxyLabelProvider.Deleted");
}
return columnText;
}
Query query = MetadataToolHelper.getQueryFromRepository(assignment.getTalendItem().getId());
if (query != null) {
if (SubItemHelper.isDeleted(query)) {
//$NON-NLS-1$
columnText += Messages.getString("RepositoryFactoryProxyLabelProvider.Deleted");
}
return columnText;
}
SAPFunctionUnit function = MetadataToolHelper.getSAPFunctionFromRepository(assignment.getTalendItem().getId());
if (function != null) {
if (SubItemHelper.isDeleted(function)) {
//$NON-NLS-1$
columnText += Messages.getString("RepositoryFactoryProxyLabelProvider.Deleted");
}
return columnText;
}
TalendItem item = assignment.getTalendItem();
if (item instanceof SQLPattern) {
List<IRepositoryViewObject> list = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.SQLPATTERNS);
for (IRepositoryViewObject obj : list) {
if (item.getLabel().equals(obj.getLabel())) {
return columnText;
}
}
} else if (item instanceof Routine) {
List<IRepositoryViewObject> list = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.ROUTINES);
for (IRepositoryViewObject obj : list) {
if (item.getLabel().equals(obj.getLabel())) {
return columnText;
}
}
}
//$NON-NLS-1$
columnText += Messages.getString("RepositoryFactoryProxyLabelProvider.NotFound");
} else if (isDeleted(lastVersion)) {
//$NON-NLS-1$
columnText += Messages.getString("RepositoryFactoryProxyLabelProvider.Deleted");
}
}
} catch (PersistenceException e) {
// e.printStackTrace();
ExceptionHandler.process(e);
}
if (columnIndex == 1) {
if (lastVersion != null) {
String label = lastVersion.getProperty().getLabel();
if (!label.equals(columnText)) {
ChangeTalendItemLabelCommand command = new ChangeTalendItemLabelCommand(((BusinessAssignment) object).getTalendItem(), label);
try {
command.execute(null, null);
} catch (ExecutionException e) {
}
return label;
}
}
}
return columnText;
}
use of org.talend.designer.business.model.business.TalendItem in project tdi-studio-se by Talend.
the class ElementHelper method updateTooltipFigure.
/**
* DOC Administrator Comment method "getTooltipFigure".
*
* @param figure
*/
public void updateTooltipFigure(Figure figure, BusinessTooltipFigure tooltipFigure, EditPart editPart) {
EObject element = ((View) editPart.getModel()).getElement();
if (element instanceof BusinessItem) {
List assignements = ((BusinessItem) element).getAssignments();
BusinessItemProviderAdapterFactory adapterFactory = new BusinessItemProviderAdapterFactory();
BusinessAssignmentItemProvider provider = (BusinessAssignmentItemProvider) adapterFactory.createBusinessAssignmentAdapter();
Image img = null;
Label label = null;
List<Label> labels = new ArrayList();
try {
for (Object assignment : assignements) {
if (assignment instanceof BusinessAssignment) {
TalendItem talendItem = ((BusinessAssignment) assignment).getTalendItem();
if (talendItem != null) {
IRepositoryViewObject obj = CorePlugin.getDefault().getProxyRepositoryFactory().getLastVersion(talendItem.getId());
if (obj != null) {
ERepositoryObjectType type = obj.getRepositoryObjectType();
Item item = obj.getProperty().getItem();
if (item instanceof JobletProcessItem) {
JobletProcessItem jobletItem = (JobletProcessItem) item;
Image jobletCustomIcon = RepositoryLabelProvider.getJobletCustomIcon(jobletItem.getProperty());
if (jobletCustomIcon != null) {
img = ImageUtils.scale(jobletCustomIcon, ICON_SIZE.ICON_16);
}
} else {
img = CoreImageProvider.getImage(type);
}
//$NON-NLS-1$ //$NON-NLS-2$
label = new Label(obj.getLabel() + " (" + provider.getColumnText(assignment, 0) + ")", img);
labels.add(label);
} else {
MetadataTable table = MetadataToolHelper.getMetadataTableFromRepository(talendItem.getId());
Query query = MetadataToolHelper.getQueryFromRepository(talendItem.getId());
SAPFunctionUnit function = MetadataToolHelper.getSAPFunctionFromRepository(talendItem.getId());
if (table != null) {
img = ImageDescriptor.createFromFile(ECoreImage.class, ECoreImage.METADATA_TABLE_ICON.getPath()).createImage();
label = new Label(talendItem.getLabel() + " (" + provider.getColumnText(assignment, 0) + ")", //$NON-NLS-1$ //$NON-NLS-2$
img);
labels.add(label);
} else if (query != null) {
img = ImageDescriptor.createFromFile(ECoreImage.class, ECoreImage.METADATA_QUERY_ICON.getPath()).createImage();
label = new Label(talendItem.getLabel() + " (" + provider.getColumnText(assignment, 0) + ")", //$NON-NLS-1$ //$NON-NLS-2$
img);
labels.add(label);
} else if (talendItem instanceof SQLPattern) {
List<IRepositoryViewObject> list = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.SQLPATTERNS);
for (IRepositoryViewObject object : list) {
if (talendItem.getLabel().equals(object.getLabel())) {
img = ImageDescriptor.createFromFile(ECoreImage.class, ECoreImage.METADATA_SQLPATTERN_ICON.getPath()).createImage();
label = new Label(//$NON-NLS-1$
talendItem.getLabel() + " (" + provider.getColumnText(assignment, 0) + ")", //$NON-NLS-1$
img);
labels.add(label);
}
}
} else if (talendItem instanceof Routine) {
List<IRepositoryViewObject> list = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.ROUTINES);
for (IRepositoryViewObject object : list) {
if (talendItem.getLabel().equals(object.getLabel())) {
img = ImageDescriptor.createFromFile(ECoreImage.class, ECoreImage.ROUTINE_ICON.getPath()).createImage();
label = new Label(//$NON-NLS-1$
talendItem.getLabel() + " (" + provider.getColumnText(assignment, 0) + ")", //$NON-NLS-1$
img);
labels.add(label);
}
}
} else if (function != null) {
img = ImageDescriptor.createFromFile(ECoreImage.class, ECoreImage.METADATA_SAPCONNECTION_ICON.getPath()).createImage();
label = new Label(talendItem.getLabel() + " (" + provider.getColumnText(assignment, 0) + ")", //$NON-NLS-1$ //$NON-NLS-2$
img);
labels.add(label);
} else {
img = (Image) provider.getImage(assignment);
img = new OverlayImage(img, ImageProvider.getImageDesc(ECoreImage.DELETED_OVERLAY), EPosition.BOTTOM_RIGHT).createImage();
String text = provider.getText(assignment) + " (" + provider.getColumnText(assignment, 0) + //$NON-NLS-1$ //$NON-NLS-2$
")";
label = new Label(text, img);
labels.add(label);
}
}
}
}
}
if (tooltipFigure == null) {
tooltipFigure = new BusinessTooltipFigure();
}
if (labels.size() == 0) {
figure.setToolTip(null);
} else {
tooltipFigure.buildFigures(labels);
figure.setToolTip(tooltipFigure);
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
use of org.talend.designer.business.model.business.TalendItem in project tdi-studio-se by Talend.
the class RepositoryHelper method createTalendItem.
public TalendItem createTalendItem(Repository repository, Object object) {
TalendItem result = null;
if (object instanceof RepositoryNode) {
RepositoryNode repositoryNode = (RepositoryNode) object;
if (repositoryNode.getType() == RepositoryNode.ENodeType.REPOSITORY_ELEMENT) {
IRepositoryViewObject repositoryObject = repositoryNode.getObject();
ERepositoryObjectType nodeType = (ERepositoryObjectType) repositoryNode.getProperties(EProperties.CONTENT_TYPE);
EClass class1 = getEClass(nodeType);
if (class1 != null) {
result = (TalendItem) BusinessFactory.eINSTANCE.create(class1);
result.setRepository(repository);
if (ERepositoryObjectType.METADATA_CON_TABLE.equals(repositoryObject.getRepositoryObjectType())) {
Property property = ((MetadataTableRepositoryObject) repositoryObject).getProperty();
Item item = property.getItem();
if (item instanceof SAPConnectionItem) {
if (repositoryNode.getParent() != null) {
result.setId(property.getId() + " - " + repositoryNode.getParent().getProperties(EProperties.LABEL) + " - " + repositoryObject.getLabel());
}
} else {
//$NON-NLS-1$
result.setId(property.getId() + " - " + repositoryObject.getLabel());
}
} else if (ERepositoryObjectType.METADATA_CON_QUERY.equals(repositoryObject.getRepositoryObjectType())) {
Property property = ((QueryRepositoryObject) repositoryObject).getProperty();
//$NON-NLS-1$
result.setId(property.getId() + " - " + repositoryObject.getLabel());
} else if (ERepositoryObjectType.METADATA_SAP_FUNCTION.equals(repositoryObject.getRepositoryObjectType())) {
Property property = ((SAPFunctionRepositoryObject) repositoryObject).getProperty();
//$NON-NLS-1$
result.setId(property.getId() + " - " + repositoryObject.getLabel());
} else {
result.setId(repositoryObject.getId());
}
result.setLabel(repositoryObject.getLabel());
}
}
}
return result;
}
Aggregations