use of com.amalto.workbench.webservices.WSGetView in project tmdm-studio-se by Talend.
the class EditXObjectAction method run.
@Override
public void run() {
try {
super.run();
if (xobject == null || !xobject.isXObject()) {
return;
}
// Access to server and get port
TMDMService service = Util.getMDMService(new URL(xobject.getEndpointAddress()), xobject.getUsername(), xobject.getPassword());
switch(xobject.getType()) {
case TreeObject.DATA_MODEL:
WSDataModel wsDataModel = service.getDataModel(new WSGetDataModel((WSDataModelPK) xobject.getWsKey()));
xobject.setWsObject(wsDataModel);
// XSDEditorUtil.openDataModel(xobject, false);
return;
case TreeObject.VIEW:
WSView wsView = service.getView(new WSGetView((WSViewPK) xobject.getWsKey()));
xobject.setWsObject(wsView);
break;
case TreeObject.DATA_CLUSTER:
WSDataCluster wsDataCluster = service.getDataCluster(new WSGetDataCluster((WSDataClusterPK) xobject.getWsKey()));
xobject.setWsObject(wsDataCluster);
break;
case TreeObject.STORED_PROCEDURE:
WSStoredProcedure wsStoredProcedure = service.getStoredProcedure(new WSGetStoredProcedure((WSStoredProcedurePK) xobject.getWsKey()));
xobject.setWsObject(wsStoredProcedure);
break;
case TreeObject.ROUTING_RULE:
WSRoutingRule wsRoutingRule = service.getRoutingRule(new WSGetRoutingRule((WSRoutingRulePK) xobject.getWsKey()));
xobject.setWsObject(wsRoutingRule);
break;
case TreeObject.TRANSFORMER:
WSTransformerV2 wsTranformer = service.getTransformerV2(new WSGetTransformerV2((WSTransformerV2PK) xobject.getWsKey()));
xobject.setWsObject(wsTranformer);
break;
case TreeObject.MENU:
WSMenu wsMenu = service.getMenu(new WSGetMenu((WSMenuPK) xobject.getWsKey()));
xobject.setWsObject(wsMenu);
break;
case TreeObject.SERVICE_CONFIGURATION:
break;
case TreeObject.JOB_REGISTRY:
// System.out.println("JOB_REGISTRY "+ xobject.getDisplayName());
break;
case TreeObject.JOB:
// System.out.println("JOB "+ xobject.getDisplayName()+" "+xobject.getWsKey());
xobject.setWsObject(xobject.getDisplayName());
break;
case TreeObject.ROLE:
if (exAdapter != null) {
exAdapter.run(service, xobject);
}
break;
case TreeObject.RESOURCES:
case TreeObject.CUSTOM_TYPE:
case TreeObject.DATA_MODEL_RESOURCE:
case TreeObject.DATA_MODEL_TYPES_RESOURCE:
case TreeObject.CUSTOM_TYPES_RESOURCE:
case TreeObject.PICTURES_RESOURCE:
break;
default:
MessageDialog.openError(getShell(), Messages._Error, Messages.bind(Messages.EditXObjectAction_ErrorMsg1, IConstants.TALEND, xobject.getType()));
return;
}
if (page == null) {
this.page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
}
this.page.openEditor(new XObjectEditorInput(xobject, xobject.getDisplayName()), // $NON-NLS-1$
"com.amalto.workbench.editors.XObjectEditor");
} catch (Exception e) {
log.error(e.getMessage(), e);
if (!Util.handleConnectionException(getShell(), e, Messages.EditXObjectAction_ErrorMsg2)) {
MessageDialog.openError(getShell(), Messages._Error, Messages.bind(Messages.EditXObjectAction_ErrorMsg2, e.getLocalizedMessage()));
}
}
}
use of com.amalto.workbench.webservices.WSGetView in project tmdm-studio-se by Talend.
the class ViewMainPage method getWsViewObject.
protected WSView getWsViewObject() {
WSView wsObject = null;
try {
if (getXObject().getWsObject() == null) {
// then fetch from server
TMDMService port = Util.getMDMService(getXObject());
wsObject = port.getView(new WSGetView((WSViewPK) getXObject().getWsKey()));
getXObject().setWsObject(wsObject);
} else {
// it has been opened by an editor - use the object there
wsObject = (WSView) getXObject().getWsObject();
}
} catch (XtentisException e) {
log.error(e.getMessage(), e);
}
return wsObject;
}
use of com.amalto.workbench.webservices.WSGetView in project tmdm-studio-se by Talend.
the class AddBrowseItemsWizard method createNewTreeObject.
private TreeObject createNewTreeObject(XSDElementDeclaration decl, String browseItem) {
WSView view = new WSView();
view.setIsTransformerActive(new WSBoolean(false));
// $NON-NLS-1$
view.setTransformerPK("");
view.setName(browseItem);
EList<XSDIdentityConstraintDefinition> idtylist = decl.getIdentityConstraintDefinitions();
List<String> keys = new ArrayList<String>();
for (XSDIdentityConstraintDefinition idty : idtylist) {
EList<XSDXPathDefinition> xpathList = idty.getFields();
for (XSDXPathDefinition path : xpathList) {
String key = decl.getName();
// remove
// $NON-NLS-1$//$NON-NLS-2$
key = key.replaceFirst("#.*", "");
// $NON-NLS-1$
key += "/" + path.getValue();
keys.add(key);
}
}
view.getSearchableBusinessElements().addAll(keys);
view.getViewableBusinessElements().addAll(keys);
StringBuffer desc = new StringBuffer();
LinkedHashMap<String, String> labels = new LinkedHashMap<String, String>();
if (decl.getAnnotation() != null) {
labels = new XSDAnnotationsStructure(decl.getAnnotation()).getLabels();
}
if (labels.size() == 0) {
// $NON-NLS-1$
labels.put("EN", decl.getName());
}
for (String lan : labels.keySet()) {
// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
desc.append("[" + lan.toUpperCase() + ":" + labels.get(lan) + "]");
}
view.setDescription(desc.toString());
WSPutView wrap = new WSPutView();
wrap.setWsView(view);
WSViewPK viewPk = new WSViewPK();
viewPk.setPk(browseItem);
WSDeleteView delView = new WSDeleteView();
delView.setWsViewPK(viewPk);
WSGetView getView = new WSGetView();
getView.setWsViewPK(viewPk);
service.putView(wrap);
// add node in the root
TreeParent root = page.getXObject().getServerRoot();
TreeObject obj = new // no storage to save
TreeObject(// no storage to save
browseItem, // no storage to save
root, // no storage to save
TreeObject.VIEW, // no storage to save
viewPk, // no storage to save
null);
return obj;
}
use of com.amalto.workbench.webservices.WSGetView in project tmdm-studio-se by Talend.
the class ViewBrowserMainPage method refreshData.
// createCharacteristicsContent
@Override
protected void refreshData() {
try {
if (viewableBEsList.isDisposed() || searchableBEsList.isDisposed() || wcListViewer.getList().isDisposed() || searchItemCombo.isDisposed() || dataClusterCombo.isDisposed()) {
return;
}
WSView view = null;
if (getXObject().getWsObject() == null) {
// then fetch from server
TMDMService port = getMDMService();
view = port.getView(new WSGetView((WSViewPK) getXObject().getWsKey()));
getXObject().setWsObject(view);
} else {
// it has been opened by an editor - use the object there
view = (WSView) getXObject().getWsObject();
}
java.util.List<String> paths = view.getViewableBusinessElements();
// Fill the vbe List
viewableBEsList.removeAll();
for (String path : paths) {
viewableBEsList.add(path);
}
paths = view.getSearchableBusinessElements();
searchableBEsList.removeAll();
searchItemCombo.removeAll();
if (paths != null) {
for (String path : paths) {
searchableBEsList.add(path);
searchItemCombo.add(path);
}
}
searchItemCombo.add(FULL_TEXT);
searchItemCombo.setText(FULL_TEXT);
wcListViewer.setInput(view);
wcListViewer.refresh();
dataClusterCombo.removeAll();
java.util.List<WSDataClusterPK> dataClusterPKs = getDataClusterPKs();
if ((dataClusterPKs == null) || (dataClusterPKs.size() == 0)) {
MessageDialog.openError(this.getSite().getShell(), Messages._Error, Messages.ViewBrowserMainPage_ErrorMsg1);
return;
}
for (WSDataClusterPK pk : dataClusterPKs) {
dataClusterCombo.add(pk.getPk());
}
dataClusterCombo.select(0);
clusterTypeCombo.setItems(getClusterTypes());
clusterTypeCombo.select(0);
this.getManagedForm().reflow(true);
searchText.setFocus();
} catch (Exception e) {
log.error(e.getMessage(), e);
if (!Util.handleConnectionException(this.getSite().getShell(), e, Messages.ViewBrowserMainPage_ErrorTitle2)) {
MessageDialog.openError(this.getSite().getShell(), Messages.ViewBrowserMainPage_ErrorTitle2, Messages.bind(Messages.ViewBrowserMainPage_ErrorMsg2, e.getLocalizedMessage()));
}
}
}
use of com.amalto.workbench.webservices.WSGetView in project tmdm-studio-se by Talend.
the class ExportItemsWizard method doexport.
public void doexport(Object[] selectedObjs, IProgressMonitor monitor) {
TreeObject[] objs = null;
if (selectedObjs.length > 0 && selectedObjs[0] instanceof TreeObject) {
objs = Arrays.asList(selectedObjs).toArray(new TreeObject[0]);
}
if (objs == null || objs.length == 0) {
return;
}
monitor.beginTask(Messages.ExportItemsWizard_Export, IProgressMonitor.UNKNOWN);
Exports eps = new Exports();
List<TreeObject> exports = new ArrayList<TreeObject>();
TMDMService service;
try {
service = Util.getMDMService(objs[0]);
try {
LocalTreeObjectRepository.getInstance().parseElementForOutput(objs);
} catch (Exception e) {
}
for (TreeObject obj : objs) {
StringWriter sw;
ArrayList<String> items;
String encodedID = null;
switch(obj.getType()) {
case TreeObject.DATA_CLUSTER:
monitor.subTask(Messages.ExportItemsWizard_2);
items = new ArrayList<String>();
// dataclusters
WSDataClusterPK pk = (WSDataClusterPK) obj.getWsKey();
try {
WSDataCluster cluster = service.getDataCluster(new WSGetDataCluster(pk));
// Marshal
sw = new StringWriter();
Marshaller.marshal(cluster, sw);
// $NON-NLS-1$
encodedID = URLEncoder.encode(cluster.getName(), "UTF-8");
// $NON-NLS-1$
writeString(sw.toString(), TreeObject.DATACONTAINER + "/" + encodedID);
// $NON-NLS-1$
items.add(TreeObject.DATACONTAINER + "/" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
} catch (Exception e) {
}
monitor.worked(1);
// datacluster contents
monitor.subTask(Messages.bind(Messages.ExportItemsWizard_3, pk.getPk()));
exportCluster(exports, pk, service);
monitor.worked(1);
break;
case TreeObject.DATA_MODEL:
monitor.subTask(Messages.ExportItemsWizard_5);
items = new ArrayList<String>();
// datamodels
try {
WSDataModel model = service.getDataModel(new WSGetDataModel((WSDataModelPK) obj.getWsKey()));
sw = new StringWriter();
Marshaller.marshal(model, sw);
// $NON-NLS-1$
encodedID = URLEncoder.encode(model.getName(), "UTF-8");
// $NON-NLS-1$
writeString(sw.toString(), TreeObject.DATAMODEL_ + "/" + encodedID);
// $NON-NLS-1$
items.add(TreeObject.DATAMODEL_ + "/" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
} catch (Exception e) {
}
monitor.worked(1);
break;
case TreeObject.MENU:
monitor.subTask(Messages.ExportItemsWizard_6);
// ExportItem exportItem=new ExportItem();
items = new ArrayList<String>();
// menu
try {
WSMenu menu = service.getMenu(new WSGetMenu((WSMenuPK) obj.getWsKey()));
// Marshal
sw = new StringWriter();
Marshaller.marshal(menu, sw);
// $NON-NLS-1$
encodedID = URLEncoder.encode(menu.getName(), "UTF-8");
// $NON-NLS-1$
writeString(sw.toString(), TreeObject.MENU_ + "/" + encodedID);
// $NON-NLS-1$
items.add(TreeObject.MENU_ + "/" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
} catch (Exception e) {
}
monitor.worked(1);
break;
case TreeObject.PICTURES_RESOURCE:
monitor.subTask(Messages.ExportItemsWizard_7);
// ExportItem exportItem=new ExportItem();
items = new ArrayList<String>();
// picture
try {
String endpointIpAddress = obj.getEndpointIpAddress();
// $NON-NLS-1$
int index = endpointIpAddress.indexOf("/services/soap");
if (index != -1) {
endpointIpAddress = endpointIpAddress.substring(0, index);
}
String picUrl = endpointIpAddress + ResourcesUtil.getResourcesMapFromURI(endpointIpAddress + TreeObject.PICTURES_URI, objs[0]).get(obj.getDisplayName());
// Marshal
sw = new StringWriter();
byte[] content = HttpClientUtil.getByteArrayContentByHttpget(picUrl);
Marshaller.marshal(content, sw);
// $NON-NLS-1$
encodedID = URLEncoder.encode(obj.getDisplayName(), "UTF-8");
// $NON-NLS-1$
writeInputStream(new ByteArrayInputStream(content), TreeObject.PICTURES_ + "/" + encodedID);
// $NON-NLS-1$
items.add(TreeObject.PICTURES_ + "/" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
monitor.worked(1);
break;
case TreeObject.ROUTING_RULE:
monitor.subTask(Messages.ExportItemsWizard_10);
// ExportItem exportItem=new ExportItem();
items = new ArrayList<String>();
// routing rule
try {
WSRoutingRule RoutingRule = service.getRoutingRule(new WSGetRoutingRule((WSRoutingRulePK) obj.getWsKey()));
// Marshal
sw = new StringWriter();
Marshaller.marshal(RoutingRule, sw);
// $NON-NLS-1$
encodedID = URLEncoder.encode(RoutingRule.getName(), "UTF-8");
// $NON-NLS-1$
writeString(sw.toString(), TreeObject.ROUTINGRULE_ + "/" + encodedID);
// $NON-NLS-1$
items.add(TreeObject.ROUTINGRULE_ + "/" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
} catch (Exception e) {
}
monitor.worked(1);
break;
case TreeObject.STORED_PROCEDURE:
monitor.subTask(Messages.ExportItemsWizard_11);
items = new ArrayList<String>();
// stored procedure
try {
WSStoredProcedure StoredProcedure = service.getStoredProcedure(new WSGetStoredProcedure((WSStoredProcedurePK) obj.getWsKey()));
// Marshal
sw = new StringWriter();
Marshaller.marshal(StoredProcedure, sw);
// $NON-NLS-1$
encodedID = URLEncoder.encode(StoredProcedure.getName(), "UTF-8");
// $NON-NLS-1$
writeString(sw.toString(), TreeObject.STOREDPROCEDURE_ + "/" + encodedID);
// $NON-NLS-1$
items.add(TreeObject.STOREDPROCEDURE_ + "/" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
} catch (Exception e) {
}
monitor.worked(1);
break;
case TreeObject.TRANSFORMER:
monitor.subTask(Messages.ExportItemsWizard_13);
items = new ArrayList<String>();
// TODO:check the pk
try {
WSTransformerV2 transformer = service.getTransformerV2(new WSGetTransformerV2(new WSTransformerV2PK(((WSTransformerV2PK) obj.getWsKey()).getPk())));
// Marshal
sw = new StringWriter();
Marshaller.marshal(transformer, sw);
// $NON-NLS-1$
encodedID = URLEncoder.encode(transformer.getName(), "UTF-8");
// $NON-NLS-1$
writeString(sw.toString(), TreeObject.TRANSFORMER_ + "/" + encodedID);
// $NON-NLS-1$
items.add(TreeObject.TRANSFORMER_ + "/" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
} catch (Exception e) {
}
monitor.worked(1);
break;
case TreeObject.VIEW:
monitor.subTask(Messages.ExportItemsWizard_15);
items = new ArrayList<String>();
// view
try {
WSView View = service.getView(new WSGetView((WSViewPK) obj.getWsKey()));
// Marshal
sw = new StringWriter();
Marshaller.marshal(View, sw);
// $NON-NLS-1$
encodedID = URLEncoder.encode(View.getName(), "UTF-8");
// $NON-NLS-1$
writeString(sw.toString(), TreeObject.VIEW_ + "/" + encodedID);
// $NON-NLS-1$
items.add(TreeObject.VIEW_ + "/" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
} catch (Exception e) {
}
monitor.worked(1);
break;
default:
IExportItemsWizardAdapter exAdapter = ExAdapterManager.getAdapter(this, IExportItemsWizardAdapter.class);
if (exAdapter != null) {
exAdapter.doexport(service, obj.getType(), exports, obj, monitor);
}
break;
}
}
// store the content xml
eps.setItems(exports.toArray(new TreeObject[exports.size()]));
eps.setSchemas(LocalTreeObjectRepository.getInstance().outPutSchemas());
// export autoincrement
try {
WSAutoIncrement auto = service.getAutoIncrement(null);
if (auto != null && auto.getAutoincrement() != null) {
eps.setAutoIncrement(auto.getAutoincrement());
}
} catch (Exception e) {
}
StringWriter sw = new StringWriter();
try {
Marshaller.marshal(eps, sw);
// $NON-NLS-1$
writeString(sw.toString(), "exportitems.xml");
} catch (Exception e) {
}
monitor.done();
} catch (Exception e) {
}
}
Aggregations