Search in sources :

Example 1 with CwmResource

use of org.talend.model.emf.CwmResource in project tdi-studio-se by Talend.

the class ImportItemUtil method createResource.

private Resource createResource(ItemRecord itemRecord, IPath path, boolean byteArrayResource) throws FileNotFoundException {
    Resource resource;
    ResourceSet resourceSet = itemRecord.getResourceSet();
    if (byteArrayResource) {
        resource = new ByteArrayResource(getURI(path));
        resourceSet.getResources().add(resource);
    } else {
        if (FileConstants.ITEM_EXTENSION.equals(path.getFileExtension())) {
            String projectName = "";
            if (itemRecord.getItemProject() != null) {
                projectName = itemRecord.getItemProject().getTechnicalLabel();
                projectName = projectName.toLowerCase();
            }
            // note: do similar code as the CwmResourceFactory
            //$NON-NLS-1$
            String business = projectName + "/businessProcess/";
            //$NON-NLS-1$
            String context = projectName + "/context/";
            //$NON-NLS-1$
            String process = projectName + "/process/";
            //$NON-NLS-1$
            String joblet = projectName + "/joblets/";
            String pathString = path.toPortableString();
            pathString = pathString.toLowerCase();
            // PTODO, maybe will bring bugs, like mr job,route, maybe jobscript
            if (pathString.contains(process) || pathString.contains(context) || pathString.contains(business) || pathString.contains(joblet)) {
                resource = new TalendXMIResource(getURI(path));
            } else {
                resource = new CwmResource(getURI(path));
            }
            resourceSet.getResources().add(resource);
        } else {
            resource = resourceSet.createResource(getURI(path));
        }
    }
    return resource;
}
Also used : CwmResource(org.talend.model.emf.CwmResource) TalendXMIResource(org.talend.commons.runtime.model.emf.TalendXMIResource) CwmResource(org.talend.model.emf.CwmResource) TalendXMIResource(org.talend.commons.runtime.model.emf.TalendXMIResource) ByteArrayResource(org.talend.core.model.properties.helper.ByteArrayResource) Resource(org.eclipse.emf.ecore.resource.Resource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) ByteArrayResource(org.talend.core.model.properties.helper.ByteArrayResource)

Aggregations

Resource (org.eclipse.emf.ecore.resource.Resource)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 TalendXMIResource (org.talend.commons.runtime.model.emf.TalendXMIResource)1 ByteArrayResource (org.talend.core.model.properties.helper.ByteArrayResource)1 CwmResource (org.talend.model.emf.CwmResource)1