use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method collectRoutines.
protected Collection<IRepositoryViewObject> collectRoutines(ExportFileResource[] process, String type) {
List<IRepositoryViewObject> toReturn = new ArrayList<IRepositoryViewObject>();
if (USER_BEANS_PATH.equals(type)) {
ERepositoryObjectType beansType = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
ICamelDesignerCoreService service = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
beansType = service.getBeansType();
}
try {
toReturn = ProxyRepositoryFactory.getInstance().getAll(beansType);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
toReturn = Collections.emptyList();
}
} else {
Set<String> allRoutinesNames = new HashSet<String>();
ERepositoryObjectType objectType = ERepositoryObjectType.ROUTINES;
if (USER_PIGUDF_PATH.equals(type)) {
objectType = ERepositoryObjectType.PIG_UDF;
}
if (ERepositoryObjectType.ROUTINES == objectType) {
for (ExportFileResource resource : process) {
if (resource.getItem() instanceof ProcessItem) {
Set<String> routinesNeededForJob = LastGenerationInfo.getInstance().getRoutinesNeededWithSubjobPerJob(resource.getItem().getProperty().getId(), resource.getItem().getProperty().getVersion());
if (routinesNeededForJob != null) {
allRoutinesNames.addAll(routinesNeededForJob);
}
}
}
} else {
for (ExportFileResource resource : process) {
if (resource.getItem() instanceof ProcessItem) {
Set<String> routinesNeededForJob = LastGenerationInfo.getInstance().getPigudfNeededWithSubjobPerJob(resource.getItem().getProperty().getId(), resource.getItem().getProperty().getVersion());
if (routinesNeededForJob != null) {
allRoutinesNames.addAll(routinesNeededForJob);
}
}
}
}
if (allRoutinesNames.isEmpty()) {
toReturn.addAll(RoutinesUtil.getCurrentSystemRoutines());
} else {
toReturn.addAll(collectRoutinesFromRepository(allRoutinesNames, objectType));
}
}
return toReturn;
}
use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.
the class AbstractStandardJobBuildProviderTest method createJobItem.
protected Item createJobItem() throws PersistenceException {
final IProxyRepositoryFactory repositoryFactory = DesignerPlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
final String testJobId = repositoryFactory.getNextId();
final String testJobLabel = StandardJobStandaloneBuildProvider.class.getSimpleName() + System.currentTimeMillis();
// copied from NewProcessWizard
Property property = PropertiesFactory.eINSTANCE.createProperty();
property.setAuthor(((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
property.setVersion(VersionUtils.DEFAULT_VERSION);
property.setStatusCode("");
property.setId(testJobId);
property.setDisplayName(testJobLabel);
property.setLabel(property.getDisplayName());
ProcessItem processItem = PropertiesFactory.eINSTANCE.createProcessItem();
processItem.setProperty(property);
property.setItem(processItem);
ProcessType process = TalendFileFactory.eINSTANCE.createProcessType();
ParametersType parameterType = TalendFileFactory.eINSTANCE.createParametersType();
List<RoutinesParameterType> dependenciesInPreference = RoutinesUtil.createDependenciesInPreference();
parameterType.getRoutinesParameter().addAll(dependenciesInPreference);
process.setParameters(parameterType);
processItem.setProcess(process);
repositoryFactory.create(processItem, new Path(""));
return processItem;
}
use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.
the class BuildJobHandlerTest method setUp.
@Before
public void setUp() throws Exception {
// Fix the NPE for org.talend.designer.core.ui.editor.process.Process.createMainParameters(Process.java:401)
bridgeProject = ReponsitoryContextBridge.getProject();
ReponsitoryContextBridge.setProject(ProjectManager.getInstance().getCurrentProject().getEmfProject());
ImportExportHandlersManager importManager = new ImportExportHandlersManager();
// job with tdm and tdq component.
URL testJobURL = FileLocator.find(Platform.getBundle("org.talend.repository.test"), new Path("/resources/testBuildJob.zip"), null);
if (testJobURL != null) {
testJobURL = FileLocator.toFileURL(testJobURL);
}
File srcFile = new File(testJobURL.getFile());
FileResourcesUnityManager fileUnityManager = ResourcesManagerFactory.getInstance().createFileUnityManager(srcFile);
ResourcesManager resManager = fileUnityManager.doUnify();
List<ImportItem> projectRecords = importManager.populateImportingItems(resManager, true, new NullProgressMonitor());
assertTrue(projectRecords.size() > 0);
importManager.importItemRecords(new NullProgressMonitor(), resManager, projectRecords, true, projectRecords.toArray(new ImportItem[0]), null);
IRepositoryViewObject obj = ProxyRepositoryFactory.getInstance().getLastVersion("_bWyBUAYbEeapTZ0aKwL_YA");
Item item = obj.getProperty().getItem();
assertTrue(item instanceof ProcessItem);
processItem = (ProcessItem) item;
}
use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.
the class FixUnevenItemContextParametersMigrationTaskTest method createTempProcessItem.
private ProcessItem createTempProcessItem() throws PersistenceException {
ProcessItem processItem = PropertiesFactory.eINSTANCE.createProcessItem();
Property myProperty = PropertiesFactory.eINSTANCE.createProperty();
myProperty.setId(ProxyRepositoryFactory.getInstance().getNextId());
ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
itemState.setDeleted(false);
itemState.setPath("");
processItem.setState(itemState);
processItem.setProperty(myProperty);
myProperty.setLabel("myJob");
myProperty.setVersion("0.1");
processItem.setProcess(TalendFileFactory.eINSTANCE.createProcessType());
ProxyRepositoryFactory.getInstance().create(processItem, new Path(""));
return processItem;
}
use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.
the class BuildJobFactoryTest method test_createBuildJobHandler_JobExportType_null.
@Test
public void test_createBuildJobHandler_JobExportType_null() {
Property property = PropertiesFactory.eINSTANCE.createProperty();
property.setAuthor(((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
property.setLabel("ABC");
property.setVersion(VersionUtils.DEFAULT_VERSION);
//$NON-NLS-1$
property.setStatusCode("");
ProcessItem processItem = PropertiesFactory.eINSTANCE.createProcessItem();
processItem.setProperty(property);
IBuildJobHandler handler = BuildJobFactory.createBuildJobHandler(processItem, "Default", property.getVersion(), JobScriptsManagerFactory.getDefaultExportChoiceMap(), (JobExportType) null);
Assert.assertNotNull("Can't build job for standalone job", handler);
Assert.assertEquals(BuildJobHandler.class.getName(), handler.getClass().getName());
}
Aggregations