Search in sources :

Example 1 with WSResourceE

use of org.talend.mdm.repository.model.mdmserverobject.WSResourceE in project tmdm-studio-se by Talend.

the class WSResourceItemImpl method getResource.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public WSResourceE getResource() {
    if (resource != null && resource.eIsProxy()) {
        InternalEObject oldResource = (InternalEObject) resource;
        resource = (WSResourceE) eResolveProxy(oldResource);
        if (resource.eResource() == null && eResource() != null) {
            URI uri = EcoreUtil.getURI(resource);
            if (uri.hasFragment()) {
                uri = uri.trimFragment();
            }
            Resource res = eResource().getResourceSet().getResource(uri, true);
            for (EObject object : res.getContents()) {
                if (object instanceof WSResourceE) {
                    resource = (WSResourceE) object;
                    break;
                }
            }
        }
        if (resource != oldResource) {
            if (eNotificationRequired()) {
                eNotify(new ENotificationImpl(this, Notification.RESOLVE, MdmpropertiesPackage.WS_RESOURCE_ITEM__RESOURCE, oldResource, resource));
            }
        }
    }
    return resource;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) EObject(org.eclipse.emf.ecore.EObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject) Resource(org.eclipse.emf.ecore.resource.Resource) WSResourceE(org.talend.mdm.repository.model.mdmserverobject.WSResourceE) URI(org.eclipse.emf.common.util.URI) InternalEObject(org.eclipse.emf.ecore.InternalEObject)

Example 2 with WSResourceE

use of org.talend.mdm.repository.model.mdmserverobject.WSResourceE in project tmdm-studio-se by Talend.

the class ResourceRepositoryFileEditorInput method init.

@Override
protected void init(Item item) {
    MDMServerObject serverObject = ((MDMServerObjectItem) item).getMDMServerObject();
    String name = null;
    if (serverObject instanceof WSResourceE) {
        // $NON-NLS-1$
        name = serverObject.getName() + "." + ((WSResourceE) serverObject).getFileExtension();
    }
    Object treeObject = new TreeObject(name, null, TreeObject.RESOURCES, null, null, null);
    setModel(treeObject);
    setName(name);
}
Also used : MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) TreeObject(com.amalto.workbench.models.TreeObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TreeObject(com.amalto.workbench.models.TreeObject) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) WSResourceE(org.talend.mdm.repository.model.mdmserverobject.WSResourceE) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)

Example 3 with WSResourceE

use of org.talend.mdm.repository.model.mdmserverobject.WSResourceE in project tmdm-studio-se by Talend.

the class WSResourceItemImpl method setResource.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setResource(WSResourceE newResource) {
    WSResourceE oldResource = resource;
    resource = newResource;
    if (eNotificationRequired()) {
        eNotify(new ENotificationImpl(this, Notification.SET, MdmpropertiesPackage.WS_RESOURCE_ITEM__RESOURCE, oldResource, resource));
    }
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) WSResourceE(org.talend.mdm.repository.model.mdmserverobject.WSResourceE)

Example 4 with WSResourceE

use of org.talend.mdm.repository.model.mdmserverobject.WSResourceE 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 5 with WSResourceE

use of org.talend.mdm.repository.model.mdmserverobject.WSResourceE 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)

Aggregations

WSResourceE (org.talend.mdm.repository.model.mdmserverobject.WSResourceE)6 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 TreeParent (com.amalto.workbench.models.TreeParent)2 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)2 Item (org.talend.core.model.properties.Item)2 MDMServerObjectItem (org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)2 MDMServerObject (org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)2 TreeObject (com.amalto.workbench.models.TreeObject)1 URI (org.eclipse.emf.common.util.URI)1 EObject (org.eclipse.emf.ecore.EObject)1 InternalEObject (org.eclipse.emf.ecore.InternalEObject)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 Clipboard (org.eclipse.swt.dnd.Clipboard)1 TextTransfer (org.eclipse.swt.dnd.TextTransfer)1 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)1 MDMServerDef (org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)1 WSResourceItem (org.talend.mdm.repository.model.mdmproperties.WSResourceItem)1