use of org.talend.commons.runtime.model.emf.TalendXMIResource 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;
}
Aggregations