use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryTransDelegate method loadTransDependency.
public TransDependency loadTransDependency(ObjectId id_dependency, List<DatabaseMeta> databases) throws KettleException {
TransDependency transDependency = new TransDependency();
try {
transDependency.setObjectId(id_dependency);
RowMetaAndData r = getTransDependency(id_dependency);
if (r != null) {
long id_connection = r.getInteger("ID_DATABASE", 0);
transDependency.setDatabase(DatabaseMeta.findDatabase(databases, new LongObjectId(id_connection)));
transDependency.setTablename(r.getString("TABLE_NAME", null));
transDependency.setFieldname(r.getString("FIELD_NAME", null));
}
return transDependency;
} catch (KettleException dbe) {
throw new KettleException(BaseMessages.getString(PKG, "TransDependency.Exception.UnableToLoadTransformationDependency") + id_dependency, dbe);
}
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryTransDelegate method loadTransHopMeta.
public TransHopMeta loadTransHopMeta(ObjectId id_trans_hop, List<StepMeta> steps) throws KettleException {
TransHopMeta hopTransMeta = new TransHopMeta();
try {
hopTransMeta.setObjectId(id_trans_hop);
RowMetaAndData r = getTransHop(id_trans_hop);
hopTransMeta.setEnabled(r.getBoolean("ENABLED", false));
long id_step_from = r.getInteger("ID_STEP_FROM", 0);
long id_step_to = r.getInteger("ID_STEP_TO", 0);
StepMeta fromStep = StepMeta.findStep(steps, new LongObjectId(id_step_from));
//
if (fromStep == null && id_step_from > 0) {
// Simply load this, we only want the name, we don't care about the
// rest...
//
StepMeta stepMeta = repository.stepDelegate.loadStepMeta(new LongObjectId(id_step_from), new ArrayList<DatabaseMeta>(), new ArrayList<PartitionSchema>());
fromStep = StepMeta.findStep(steps, stepMeta.getName());
}
if (fromStep == null) {
log.logError("Unable to determine source step of transformation hop with ID: " + id_trans_hop);
// Invalid hop, simply ignore. See: PDI-2446
return null;
}
hopTransMeta.setFromStep(fromStep);
hopTransMeta.getFromStep().setDraw(true);
hopTransMeta.setToStep(StepMeta.findStep(steps, new LongObjectId(id_step_to)));
//
if (hopTransMeta.getToStep() == null && id_step_to > 0) {
// Simply load this, we only want the name, we don't care about
// the rest...
StepMeta stepMeta = repository.stepDelegate.loadStepMeta(new LongObjectId(id_step_to), new ArrayList<DatabaseMeta>(), new ArrayList<PartitionSchema>());
hopTransMeta.setToStep(StepMeta.findStep(steps, stepMeta.getName()));
}
if (hopTransMeta.getFromStep() == null || hopTransMeta.getFromStep() == null) {
//
return null;
}
hopTransMeta.getToStep().setDraw(true);
return hopTransMeta;
} catch (KettleDatabaseException dbe) {
throw new KettleException(BaseMessages.getString(PKG, "TransHopMeta.Exception.LoadTransformationHopInfo") + id_trans_hop, dbe);
}
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryTransDelegate method getTransformationsWithIDList.
public String[] getTransformationsWithIDList(ObjectId[] ids) throws KettleException {
String[] transList = new String[ids.length];
for (int i = 0; i < ids.length; i++) {
ObjectId id_transformation = ids[i];
if (id_transformation != null) {
RowMetaAndData transRow = getTransformation(id_transformation);
if (transRow != null) {
String transName = transRow.getString(KettleDatabaseRepository.FIELD_TRANSFORMATION_NAME, "<name not found>");
long id_directory = transRow.getInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_DIRECTORY, -1L);
RepositoryDirectoryInterface dir = repository.loadRepositoryDirectoryTree().findDirectory(new LongObjectId(id_directory));
transList[i] = dir.getPathObjectCombination(transName);
}
}
}
return transList;
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryMetaStore method getElements.
@Override
public List<IMetaStoreElement> getElements(String namespace, IMetaStoreElementType elementType) throws MetaStoreException {
try {
IMetaStoreElementType type = getElementTypeByName(namespace, elementType.getName());
if (type == null) {
return new ArrayList<IMetaStoreElement>();
}
Collection<RowMetaAndData> elementRows = delegate.getElements(new LongObjectId(new StringObjectId(type.getId())));
List<IMetaStoreElement> elements = new ArrayList<IMetaStoreElement>();
for (RowMetaAndData elementRow : elementRows) {
IMetaStoreElement element = delegate.parseElement(elementType, elementRow);
elements.add(element);
}
return elements;
} catch (Exception e) {
throw new MetaStoreException("Unable to get list of elements from namespace '" + namespace + "' and for element type '" + elementType.getName() + "'", e);
}
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryMetaStore method updateElementType.
@Override
public void updateElementType(String namespace, IMetaStoreElementType elementType) throws MetaStoreException {
try {
ObjectId namespaceId = delegate.verifyNamespace(namespace);
String elementTypeId = elementType.getId();
if (elementTypeId == null) {
IMetaStoreElementType type = getElementTypeByName(namespace, elementType.getName());
if (type != null) {
elementTypeId = type.getId();
}
}
if (elementTypeId != null) {
delegate.updateElementType(namespaceId, new LongObjectId(new StringObjectId(elementType.getId())), elementType);
repository.commit();
} else {
throw new MetaStoreException("Unable to update element type: no id was provided and the name '" + elementType.getName() + "' didn't match");
}
} catch (MetaStoreException e) {
throw e;
} catch (Exception e) {
repository.rollback();
throw new MetaStoreException("Unable to update element type", e);
}
}
Aggregations