use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryMetaStore method getElementByName.
@Override
public IMetaStoreElement getElementByName(String namespace, IMetaStoreElementType elementType, String name) throws MetaStoreException {
try {
LongObjectId namespaceId = delegate.getNamespaceId(namespace);
if (namespaceId == null) {
return null;
}
LongObjectId elementTypeId = delegate.getElementTypeId(namespaceId, elementType.getName());
if (elementTypeId == null) {
return null;
}
LongObjectId elementId = delegate.getElementId(elementTypeId, name);
if (elementId == null) {
return null;
}
RowMetaAndData elementRow = delegate.getElement(elementId);
if (elementRow == null) {
return null;
}
return delegate.parseElement(elementType, elementRow);
} catch (Exception e) {
throw new MetaStoreException("Unable to get element by name '" + name + "' from namespace '" + namespace + "'", e);
}
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryMetaStore method getElementType.
@Override
public IMetaStoreElementType getElementType(String namespace, String elementTypeId) throws MetaStoreException {
try {
ObjectId namespaceId = delegate.getNamespaceId(namespace);
if (namespaceId == null) {
return null;
}
RowMetaAndData elementTypeRow = delegate.getElementType(new LongObjectId(new StringObjectId(elementTypeId)));
return delegate.parseElementType(namespace, namespaceId, elementTypeRow);
} catch (Exception e) {
throw new MetaStoreException("Unable to get element type with id '" + elementTypeId + "' in namespace '" + namespace + "'", e);
}
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryConditionDelegate method lookupValue.
public synchronized ObjectId lookupValue(String name, String type, String value_str, boolean isnull) throws KettleException {
RowMetaAndData table = new RowMetaAndData();
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_VALUE_NAME), name);
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_VALUE_VALUE_TYPE), type);
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_VALUE_VALUE_STR), value_str);
table.addValue(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_VALUE_IS_NULL), Boolean.valueOf(isnull));
String sql = "SELECT " + quote(KettleDatabaseRepository.FIELD_VALUE_ID_VALUE) + " FROM " + quoteTable(KettleDatabaseRepository.TABLE_R_VALUE) + " ";
sql += "WHERE " + quote(KettleDatabaseRepository.FIELD_VALUE_NAME) + " = ? ";
sql += "AND " + quote(KettleDatabaseRepository.FIELD_VALUE_VALUE_TYPE) + " = ? ";
sql += "AND " + quote(KettleDatabaseRepository.FIELD_VALUE_VALUE_STR) + " = ? ";
sql += "AND " + quote(KettleDatabaseRepository.FIELD_VALUE_IS_NULL) + " = ? ";
RowMetaAndData result = repository.connectionDelegate.getOneRow(sql, table.getRowMeta(), table.getData());
if (result != null && result.getData() != null && result.isNumeric(0)) {
return new LongObjectId(result.getInteger(0, 0L));
} else {
return null;
}
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryConnectionDelegate method getTransAttributes.
public synchronized List<Object[]> getTransAttributes(ObjectId id_transformation, String code, long nr) throws KettleException {
String sql = "SELECT *" + " FROM " + databaseMeta.getQuotedSchemaTableCombination(null, KettleDatabaseRepository.TABLE_R_TRANS_ATTRIBUTE) + " WHERE " + quote(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_ID_TRANSFORMATION) + " = ? AND " + quote(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_CODE) + " = ? AND " + quote(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_NR) + " = ?" + " ORDER BY " + quote(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_VALUE_NUM);
RowMetaAndData table = new RowMetaAndData();
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_ID_TRANSFORMATION), new LongObjectId(id_transformation));
table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_CODE), code);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_NR), new Long(nr));
return callRead(() -> database.getRows(sql, table.getRowMeta(), table.getData(), ResultSet.FETCH_FORWARD, false, 0, null));
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryConnectionDelegate method getIDWithValue.
public synchronized ObjectId getIDWithValue(String tablename, String idfield, String lookupfield, String value, String lookupkey, ObjectId key) throws KettleException {
RowMetaAndData par = new RowMetaAndData();
par.addValue(new ValueMetaString("value"), value);
par.addValue(new ValueMetaInteger("key"), new LongObjectId(key));
RowMetaAndData result = getOneRow("SELECT " + idfield + " FROM " + tablename + " WHERE " + lookupfield + " = ? AND " + lookupkey + " = ?", par.getRowMeta(), par.getData());
if (result != null && result.getRowMeta() != null && result.getData() != null && result.isNumeric(0)) {
return new LongObjectId(result.getInteger(0, 0));
}
return null;
}
Aggregations