Search in sources :

Example 36 with TreeParent

use of com.amalto.workbench.models.TreeParent in project tmdm-studio-se by Talend.

the class ImportServerObjectWizard method handlePictureResourceObject.

/**
 * DOC hbhong Comment method "handlePictureResourceObject".
 *
 * @param treeObj
 * @throws IOException
 */
private WSResourceE handlePictureResourceObject(TreeObject treeObj) throws IOException {
    if (treeObj != null) {
        if (treeObj instanceof TreeParent) {
            return null;
        }
        String[] fileInfo = getPicResourceFileInfo(treeObj.getName());
        if (fileInfo != null) {
            String dirName = fileInfo[0];
            String fileQName = fileInfo[1];
            String fileExtension = fileInfo[2];
            String fileName = fileInfo[3];
            // encode the dirName and fileName
            String encodedDirName = URLEncoder.encode(dirName, UTF8);
            fileQName = URLEncoder.encode(fileQName, UTF8);
            WSResourceE resource = MdmserverobjectFactory.eINSTANCE.createWSResourceE();
            resource.setName(fileName);
            resource.setFileExtension(fileExtension);
            StringBuffer strBuf = new StringBuffer();
            strBuf.append(serverDef.getProtocol()).append(serverDef.getHost()).append(":").append(// $NON-NLS-1$
            serverDef.getPort()).append(Util.getContextPath(serverDef.getPath())).append("/services/imageserver/upload/").append(encodedDirName).append("/").append(fileQName).append(".").append(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            fileExtension);
            String url = strBuf.toString();
            byte[] bytes = HttpClientUtil.downloadFile(url, serverDef.getUser(), serverDef.getPasswd());
            resource.setFileContent(bytes);
            // add imageCatalog
            resource.setImageCatalog(dirName);
            treeObj.setName(fileName);
            return resource;
        }
    }
    return null;
}
Also used : TreeParent(com.amalto.workbench.models.TreeParent) WSResourceE(org.talend.mdm.repository.model.mdmserverobject.WSResourceE)

Example 37 with TreeParent

use of com.amalto.workbench.models.TreeParent in project tmdm-studio-se by Talend.

the class AbstractNodeCheckTreeViewer method isExist.

private boolean isExist(TreeObject treeObj) {
    if (treeObj instanceof TreeParent) {
        return false;
    }
    int type = treeObj.getType();
    ERepositoryObjectType rType = RepositoryQueryService.getRepositoryObjectType(type);
    if (rType == null) {
        return false;
    }
    List<IRepositoryViewObject> children = RepositoryResourceUtil.findAllViewObjectsWithDeleted(rType);
    if (children == null) {
        return false;
    }
    String treeObjName = treeObj.getName();
    if (type == TreeObject.PICTURES_RESOURCE) {
        // $NON-NLS-1$
        int index = treeObjName.indexOf("-");
        if (index > 0) {
            treeObjName = treeObjName.substring(index + 1);
        }
    }
    for (IRepositoryViewObject viewObject : children) {
        Item item = viewObject.getProperty().getItem();
        if (item instanceof MDMServerObjectItem) {
            MDMServerObject serverObj = ((MDMServerObjectItem) item).getMDMServerObject();
            String name = serverObj.getName();
            if (type == TreeObject.WORKFLOW_PROCESS) {
                // $NON-NLS-1$
                name = name + "_" + viewObject.getVersion();
            }
            if (type == TreeObject.PICTURES_RESOURCE) {
                // $NON-NLS-1$ //$NON-NLS-2$
                name = name + "_" + viewObject.getVersion() + "." + ((WSResourceE) serverObj).getFileExtension();
            }
            if (serverObj != null && treeObjName.equals(name)) {
                return true;
            }
        }
    }
    return false;
}
Also used : Item(org.talend.core.model.properties.Item) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) TreeParent(com.amalto.workbench.models.TreeParent) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) WSResourceE(org.talend.mdm.repository.model.mdmserverobject.WSResourceE) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)

Example 38 with TreeParent

use of com.amalto.workbench.models.TreeParent in project tmdm-studio-se by Talend.

the class RepositoryWebServiceAdapter method resetXObject.

public static void resetXObject(MDMServerDef serverDef, TreeObject xobject) {
    String serverName = serverDef.getHost();
    String username = serverDef.getUser();
    String password = serverDef.getPasswd();
    String endpointaddress = // $NON-NLS-1$
    serverDef.getProtocol() + serverDef.getHost() + ":" + serverDef.getPort() + serverDef.getPath();
    TreeParent serverRoot = new TreeParent(serverName, null, TreeObject._SERVER_, endpointaddress, username + ":" + // $NON-NLS-1$//$NON-NLS-2$
    (password == null ? "" : password));
    UserInfo user = new UserInfo();
    user.setUsername(username);
    user.setPassword(password);
    user.setServerUrl(endpointaddress);
    serverRoot.setUser(user);
    xobject.setServerRoot(serverRoot);
}
Also used : TreeParent(com.amalto.workbench.models.TreeParent) UserInfo(com.amalto.workbench.utils.UserInfo)

Aggregations

TreeParent (com.amalto.workbench.models.TreeParent)38 TreeObject (com.amalto.workbench.models.TreeObject)21 Document (org.dom4j.Document)7 Element (org.dom4j.Element)7 GridData (org.eclipse.swt.layout.GridData)7 UserInfo (com.amalto.workbench.utils.UserInfo)6 ArrayList (java.util.ArrayList)6 GridLayout (org.eclipse.swt.layout.GridLayout)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 Composite (org.eclipse.swt.widgets.Composite)5 WSDataClusterPK (com.amalto.workbench.webservices.WSDataClusterPK)4 HashMap (java.util.HashMap)4 SelectionListener (org.eclipse.swt.events.SelectionListener)4 Combo (org.eclipse.swt.widgets.Combo)4 Label (org.eclipse.swt.widgets.Label)4 XtentisException (com.amalto.workbench.utils.XtentisException)3 WSDataModel (com.amalto.workbench.webservices.WSDataModel)3 WSDataModelPK (com.amalto.workbench.webservices.WSDataModelPK)3 WSGetDataModel (com.amalto.workbench.webservices.WSGetDataModel)3 ModifyEvent (org.eclipse.swt.events.ModifyEvent)3