use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class ChangeDefaultSparkSerializer method changeSparkConfiguration.
private void changeSparkConfiguration(ProcessType processType, Item item) throws PersistenceException {
boolean modified = false;
final ParametersType parameters = processType.getParameters();
if (parameters != null) {
EList elementParameters = parameters.getElementParameter();
ElementParameterType property = TalendFileFactory.eINSTANCE.createElementParameterType();
//$NON-NLS-1$
property.setName("CUSTOMIZE_SPARK_SERIALIZER");
//$NON-NLS-1$
property.setField("CHECK");
//$NON-NLS-1$
property.setValue("true");
elementParameters.add(property);
property = TalendFileFactory.eINSTANCE.createElementParameterType();
//$NON-NLS-1$
property.setName("SPARK_SERIALIZER");
//$NON-NLS-1$
property.setField("TEXT");
//$NON-NLS-1$
property.setValue("\"org.apache.spark.serializer.JavaSerializer\"");
elementParameters.add(property);
for (int i = 0; i < elementParameters.size(); i++) {
ElementParameterType param = (ElementParameterType) elementParameters.get(i);
if ("ADVANCED_SETTINGS_CHECK".equals(param.getName())) {
//$NON-NLS-1$
//$NON-NLS-1$
param.setValue("true");
modified = true;
break;
}
}
}
if (modified) {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
factory.save(item, true);
}
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class RemoveUseHadoopPropertiesFortMRConfiguration method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (processType != null) {
boolean modified = false;
final ParametersType parameters = processType.getParameters();
if (parameters != null) {
EList elementParameters = parameters.getElementParameter();
for (int i = 0; i < elementParameters.size(); i++) {
ElementParameterType param = (ElementParameterType) elementParameters.get(i);
if ("USE_HADOOP_PROPERTIES".equals(param.getName())) {
//$NON-NLS-1$ //$NON-NLS-2$
if ("false".equalsIgnoreCase(param.getValue())) {
for (int j = 0; j < elementParameters.size(); j++) {
ElementParameterType hadoopProps = (ElementParameterType) elementParameters.get(j);
if ("HADOOP_ADVANCED_PROPERTIES".equalsIgnoreCase(hadoopProps.getName())) {
hadoopProps.getElementValue().clear();
}
}
}
elementParameters.remove(param);
modified = true;
break;
}
}
}
if (modified) {
try {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
factory.save(item, true);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
}
return ExecutionResult.NOTHING_TO_DO;
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class ChangeLocalModeForSparkConfiguration method execute.
@Override
public ExecutionResult execute(Item item) {
try {
ProcessType processType = getProcessType(item);
if (processType != null) {
final ParametersType parameters = processType.getParameters();
if (parameters != null) {
boolean modified = false;
EList<ElementParameterType> elementParameters = parameters.getElementParameter();
for (int i = 0; i < elementParameters.size(); i++) {
ElementParameterType param = elementParameters.get(i);
if ("SPARK_MODE".equals(param.getName())) {
//$NON-NLS-1$
modified = true;
ElementParameterType property = TalendFileFactory.eINSTANCE.createElementParameterType();
//$NON-NLS-1$
property.setName("SPARK_LOCAL_MODE");
//$NON-NLS-1$
property.setField("CHECK");
//$NON-NLS-1$
property.setValue("false");
if ("LOCAL".equalsIgnoreCase(param.getValue())) {
//$NON-NLS-1$
//$NON-NLS-1$
param.setValue("CLUSTER");
//$NON-NLS-1$
property.setValue("true");
}
elementParameters.add(property);
break;
}
}
if (modified) {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
factory.save(item, true);
return ExecutionResult.SUCCESS_NO_ALERT;
}
}
}
} catch (PersistenceException e) {
return ExecutionResult.FAILURE;
}
return ExecutionResult.NOTHING_TO_DO;
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class QueryGuessCommandTest method generateNewTeradataQuery2.
@Test
public void generateNewTeradataQuery2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, PersistenceException {
ProxyRepositoryFactory repFactory = ProxyRepositoryFactory.getInstance();
String propertyId = repFactory.getNextId();
try {
DatabaseConnection connection = ConnectionFactory.eINSTANCE.createDatabaseConnection();
connection.setSID("myschema");
Property connectionProperty = PropertiesFactory.eINSTANCE.createProperty();
connectionProperty.setAuthor(((RepositoryContext) CoreRuntimePlugin.getInstance().getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
connectionProperty.setVersion(VersionUtils.DEFAULT_VERSION);
//$NON-NLS-1$
connectionProperty.setStatusCode("");
connectionProperty.setId(propertyId);
connectionProperty.setLabel("test_connection");
ConnectionItem connectionItem = PropertiesFactory.eINSTANCE.createDatabaseConnectionItem();
connectionItem.setProperty(connectionProperty);
connectionItem.setConnection(connection);
repFactory.create(connectionItem, new Path(""));
node = Mockito.mock(INode.class);
connection.setContextMode(true);
TdTable table = RelationalFactory.eINSTANCE.createTdTable();
table.setName("tableName");
table.setLabel("tableLabel");
TdColumn column1 = RelationalFactory.eINSTANCE.createTdColumn();
column1.setName("id");
TdColumn column2 = RelationalFactory.eINSTANCE.createTdColumn();
column2.setName("name");
table.getColumns().add(column1);
table.getColumns().add(column2);
metadataTable = ConvertionHelper.convert(table);
ElementParameter parameter = new ElementParameter(node);
parameter.setName("DBTABLE");
parameter.setValue(table.getName());
Mockito.when(node.getPropertyValue(EParameterName.PROPERTY_TYPE.getName())).thenReturn("REPOSITORY");
Mockito.when(node.getElementParameterFromField(EParameterFieldType.DBTABLE)).thenReturn(parameter);
ElementParameter connectionId = new ElementParameter(node);
connectionId.setValue(connectionProperty.getId());
Mockito.when(node.getElementParameter(EParameterName.REPOSITORY_PROPERTY_TYPE.getName())).thenReturn(connectionId);
// test case 1
String schema = "";
String dbType = EDatabaseTypeName.TERADATA.getDisplayName();
String expectedQuery = "\"SELECT myschema.tableName.\\\"id\\\", myschema.tableName.name FROM myschema.tableName\"";
QueryGuessCommand command = new QueryGuessCommand(node, metadataTable, schema, dbType, connection);
Method method = command.getClass().getDeclaredMethod("generateNewQuery");
method.setAccessible(true);
String queryString = (String) method.invoke(command);
Assert.assertEquals(expectedQuery, queryString);
} catch (Exception e) {
throw e;
} finally {
IRepositoryViewObject lastVersion = repFactory.getLastVersion(propertyId);
if (lastVersion != null) {
repFactory.deleteObjectPhysical(lastVersion);
}
}
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tesb-studio-se by Talend.
the class KarafJavaScriptForESBWithMavenManager method analysisMavenModule.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected void analysisMavenModule(Item item) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
if (camelService.isInstanceofCamelRoutes(item)) {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
List<String> mavenModules = getMavenModules();
mavenModules.clear();
talendJobsMap.clear();
EList nodes = ((CamelProcessItem) item).getProcess().getNode();
for (NodeType node : (List<NodeType>) nodes) {
if ("cTalendJob".equals(node.getComponentName())) {
//$NON-NLS-1$
String talendJobId = null;
String talendJobVersion = null;
String talendJobContextGroup = null;
EList elementParameters = node.getElementParameter();
for (ElementParameterType paramType : (List<ElementParameterType>) elementParameters) {
if ("SELECTED_JOB_NAME:PROCESS_TYPE_PROCESS".equals(paramType.getName())) {
//$NON-NLS-1$
talendJobId = paramType.getValue();
} else if ("SELECTED_JOB_NAME:PROCESS_TYPE_VERSION".equals(paramType.getName())) {
//$NON-NLS-1$
talendJobVersion = paramType.getValue();
} else if ("SELECTED_JOB_NAME:PROCESS_TYPE_CONTEXT".equals(paramType.getName())) {
//$NON-NLS-1$
talendJobContextGroup = paramType.getValue();
}
if (talendJobId != null && talendJobVersion != null && talendJobContextGroup != null) {
// found
break;
}
}
if (talendJobId != null) {
if (talendJobVersion == null) {
talendJobVersion = RelationshipItemBuilder.LATEST_VERSION;
}
if (talendJobContextGroup == null) {
talendJobContextGroup = IContext.DEFAULT;
}
IRepositoryViewObject foundObject = null;
try {
if (RelationshipItemBuilder.LATEST_VERSION.equals(talendJobVersion)) {
foundObject = factory.getLastVersion(talendJobId);
} else {
// find out the fixing version
List<IRepositoryViewObject> allVersionObjects = factory.getAllVersion(talendJobId);
if (allVersionObjects != null) {
for (IRepositoryViewObject obj : allVersionObjects) {
if (obj.getVersion().equals(talendJobVersion)) {
foundObject = obj;
break;
}
}
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (foundObject != null) {
Property property = foundObject.getProperty();
if (property != null) {
talendJobsMap.put(talendJobId, foundObject);
talendJobContextGroupsMap.put(talendJobId, talendJobContextGroup);
// we do not export the referenced jobs literally,
// but get them for build from the Maven repository.
// Thus, we must not add module declarations for them.
// mavenModules.add(TALEND_JOBS_PATH + property.getLabel());
}
}
}
}
}
}
}
}
Aggregations