use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class DBTreeProvider method getMetadataConnection.
/**
* @return MetadataConnection
*/
@SuppressWarnings("unchecked")
private Container getMetadataConnection() {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
ProjectManager pManager = ProjectManager.getInstance();
Container container = null;
try {
container = factory.getMetadata(pManager.getCurrentProject(), ERepositoryObjectType.METADATA_CONNECTIONS);
pManager.retrieveReferencedProjects();
for (Project p : pManager.getAllReferencedProjects()) {
RootContainer rContainer = factory.getMetadata(p, ERepositoryObjectType.METADATA_CONNECTIONS);
if (container == null) {
container = rContainer;
} else if (rContainer != null) {
Iterator iterator = rContainer.absoluteKeySet().iterator();
while (iterator.hasNext()) {
Object id = iterator.next();
container.addMember(id, rContainer.getAbsoluteMember(id));
}
}
}
} catch (PersistenceException e) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("DBTreeProvider.logMessage"), e);
} catch (BusinessException e) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("DBTreeProvider.logMessage"), e);
}
return container;
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class DBTreeProvider method addNode.
private void addNode(RepositoryNode parent, IRepositoryViewObject repositoryObject, boolean isBuildIn, Integer index) {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
DatabaseConnection connection = (DatabaseConnection) ((ConnectionItem) repositoryObject.getProperty().getItem()).getConnection();
String sid = connection.getSID();
MetadataConnectionRepositoryObject connectionRepositoryObject = new MetadataConnectionRepositoryObject(repositoryObject);
if (isBuildIn) {
connectionRepositoryObject.setRepositoryName(BUILT_IN);
} else {
connectionRepositoryObject.setRepositoryName(repositoryObject.getLabel());
}
//$NON-NLS-1$
connectionRepositoryObject.setSourceName((sid == null || sid.trim().equals("")) ? connection.getDatasourceName() : sid);
if (!isBuildIn) {
connectionRepositoryObject.setImage(IMAGES_CONNECTION_ICON);
} else {
connectionRepositoryObject.setImage(IMAGES_DATABASE_ICON);
}
connectionRepositoryObject.setBuildIn(isBuildIn);
RepositoryNode node = new RepositoryNodeExt(connectionRepositoryObject, parent, ENodeType.REPOSITORY_ELEMENT);
node.setProperties(EProperties.CONTENT_TYPE, RepositoryNodeType.DATABASE);
node.setProperties(EProperties.LABEL, repositoryObject.getLabel());
boolean[] isDiffs = repositoryNodeManager.isDiff(node);
if (isDiffs[0]) {
connectionRepositoryObject.setDiffImage(IMAGES_GRAY_ICON);
}
if (isDiffs[1]) {
connectionRepositoryObject.setDiffImage(IMAGES_RED_ICON);
}
if (isDiffs[2]) {
connectionRepositoryObject.setDiffImage(IMAGES_REFRESH_ICON);
}
if (factory.getStatus(repositoryObject) == ERepositoryStatus.DELETED) {
// ignore recycle node
} else {
if (index == null) {
parent.getChildren().add(node);
} else {
parent.getChildren().add(index.intValue(), node);
}
repositoryNodeManager.addRepositoryNode(node);
DatabaseConnection metadataConnection = (DatabaseConnection) ((ConnectionItem) repositoryObject.getProperty().getItem()).getConnection();
createTables(node, repositoryObject, metadataConnection, isBuildIn);
createQueries(node, repositoryObject, metadataConnection, isBuildIn);
}
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class MigrateDeprecatedHadoopDistribution1 method changeMRConfiguration.
private void changeMRConfiguration(ProcessType processType, Item item) throws PersistenceException {
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 ("MR_VERSION".equals(param.getName())) {
//$NON-NLS-1$
if (values.containsKey(param.getValue())) {
param.setValue(values.get(param.getValue()));
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 RenameDbMacroMigrationTask method convertItem.
private boolean convertItem(Item item, ProcessType processType) throws PersistenceException {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
EList node = processType.getNode();
for (Object n : node) {
NodeType type = (NodeType) n;
EList elementParameterList = type.getElementParameter();
for (Object elem : elementParameterList) {
ElementParameterType elemType = (ElementParameterType) elem;
if (elemType.getName().equals("DBTABLE")) {
//$NON-NLS-1$
//$NON-NLS-1$
elemType.setName("TABLE");
modified = true;
}
}
}
if (modified) {
factory.save(item, true);
}
return modified;
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class RenameModeParaForPigMigrationTask method renameModeName.
private void renameModeName(Item item) {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
ProcessType processType = getProcessType(item);
for (Object object : processType.getNode()) {
if (object instanceof NodeType) {
NodeType currentNode = (NodeType) object;
if (currentNode.getComponentName().startsWith("tPigLoad")) {
//$NON-NLS-1$
for (Object o : currentNode.getElementParameter()) {
ElementParameterType para = (ElementParameterType) o;
if ("MODE".equals(para.getName())) {
//$NON-NLS-1$
//$NON-NLS-1$
para.setName("DB_VERSION");
if ("local".equals(para.getValue()))
para.setValue("pig.jar");
if ("mapreduce".equals(para.getValue()))
para.setValue("pig-withouthadoop.jar;hadoop-conf.jar;hadoop-0.20.2-core.jar");
modified = true;
break;
}
}
}
}
}
if (modified) {
try {
factory.save(item, true);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
Aggregations