Search in sources :

Example 1 with CreateMavenStandardJobOSGiPom

use of org.talend.designer.maven.tools.creator.CreateMavenStandardJobOSGiPom in project tdi-studio-se by Talend.

the class StandardJobOSGiBundleBuildProvider method createPomCreator.

@Override
public IMavenPomCreator createPomCreator(Map<String, Object> parameters) {
    if (parameters == null || parameters.isEmpty()) {
        return null;
    }
    final Object processor = parameters.get(PROCESSOR);
    if (processor == null || !(processor instanceof IProcessor)) {
        return null;
    }
    final Object pomFile = parameters.get(FILE_POM);
    if (pomFile == null || !(pomFile instanceof IFile)) {
        return null;
    }
    final Object item = parameters.get(ITEM);
    if (item == null || !(item instanceof Item)) {
        return null;
    }
    Object argumentsMap = parameters.get(ARGUMENTS_MAP);
    if (argumentsMap == null) {
        argumentsMap = Collections.emptyMap();
    }
    if (!(argumentsMap instanceof Map)) {
        return null;
    }
    Object overwrite = parameters.get(OVERWRITE_POM);
    if (overwrite == null) {
        overwrite = Boolean.FALSE;
    }
    CreateMavenStandardJobOSGiPom osgiPomCreator = new CreateMavenStandardJobOSGiPom((IProcessor) processor, (IFile) pomFile);
    osgiPomCreator.setArgumentsMap((Map<String, Object>) argumentsMap);
    osgiPomCreator.setOverwrite(Boolean.parseBoolean(overwrite.toString()));
    final Property itemProperty = ((Item) item).getProperty();
    IPath itemLocationPath = ItemResourceUtil.getItemLocationPath(itemProperty);
    IFolder objectTypeFolder = ItemResourceUtil.getObjectTypeFolder(itemProperty);
    if (itemLocationPath != null && objectTypeFolder != null) {
        IPath itemRelativePath = itemLocationPath.removeLastSegments(1).makeRelativeTo(objectTypeFolder.getLocation());
        osgiPomCreator.setObjectTypeFolder(objectTypeFolder);
        osgiPomCreator.setItemRelativePath(itemRelativePath);
    }
    return osgiPomCreator;
}
Also used : CreateMavenStandardJobOSGiPom(org.talend.designer.maven.tools.creator.CreateMavenStandardJobOSGiPom) Item(org.talend.core.model.properties.Item) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) IProcessor(org.talend.designer.runprocess.IProcessor) Map(java.util.Map) Property(org.talend.core.model.properties.Property) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

Map (java.util.Map)1 IFile (org.eclipse.core.resources.IFile)1 IFolder (org.eclipse.core.resources.IFolder)1 IPath (org.eclipse.core.runtime.IPath)1 Item (org.talend.core.model.properties.Item)1 Property (org.talend.core.model.properties.Property)1 CreateMavenStandardJobOSGiPom (org.talend.designer.maven.tools.creator.CreateMavenStandardJobOSGiPom)1 IProcessor (org.talend.designer.runprocess.IProcessor)1