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;
}
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);
}
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));
}
}
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;
}
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;
}
Aggregations