/** * Sets the id for the job entry * * @param id * the new id */ public void setID( long id ) { this.id = new LongObjectId( id ); }
public static final ObjectId[] convertLongList( List<Long> list ) { ObjectId[] ids = new ObjectId[ list.size() ]; for ( int i = 0; i < ids.length; i++ ) { ids[ i ] = new LongObjectId( list.get( i ) ); } return ids; }
public Map<String, LongObjectId> getValueToIdMap( String tablename, String idfield, String lookupfield ) throws KettleException { String sql = new StringBuilder( "SELECT " ).append( lookupfield ).append( ", " ).append( idfield ) .append( " FROM " ).append( tablename ).toString(); Map<String, LongObjectId> result = new HashMap<String, LongObjectId>(); for ( Object[] row : callRead( () -> database.getRows( sql, new RowMeta(), new Object[] {}, ResultSet.FETCH_FORWARD, false, -1, null ) ) ) { result.put( String.valueOf( row[ 0 ] ), new LongObjectId( ( (Number) row[ 1 ] ).longValue() ) ); } return result; }
public DatabaseMeta loadDatabaseMetaFromStepAttribute( ObjectId idStep, String code, List<DatabaseMeta> databases ) throws KettleException { long id_database = getStepAttributeInteger( idStep, code ); if ( id_database <= 0 ) { return null; } return DatabaseMeta.findDatabase( databases, new LongObjectId( id_database ) ); }
@Override public void setId( String id ) { this.objectId = new LongObjectId( new StringObjectId( id ) ); }
public KDBRMetaStoreElement parseElement( IMetaStoreElementType elementType, RowMetaAndData elementRow ) throws KettleException { Long elementId = elementRow.getInteger( KettleDatabaseRepository.FIELD_ELEMENT_ID_ELEMENT ); String name = elementRow.getString( KettleDatabaseRepository.FIELD_ELEMENT_NAME, null ); KDBRMetaStoreElement element = new KDBRMetaStoreElement( this, elementType, Long.toString( elementId ), null ); element.setName( name ); // Now load the attributes... // addAttributes( element, new LongObjectId( elementId ), new LongObjectId( 0 ) ); return element; }
public RepositoryDirectoryInterface loadRepositoryDirectoryTree() throws KettleException { RepositoryDirectory root = new RepositoryDirectory(); root.setObjectId( new LongObjectId( 0L ) ); return directoryDelegate.loadRepositoryDirectoryTree( root ); }
public DatabaseMeta loadDatabaseMetaFromJobEntryAttribute( ObjectId id_jobentry, String nameCode, int nr, String idCode, List<DatabaseMeta> databases ) throws KettleException { long id_database = getJobEntryAttributeInteger( id_jobentry, nr, idCode ); if ( id_database <= 0 ) { String name = getJobEntryAttributeString( id_jobentry, nr, nameCode ); if ( name == null ) { return null; } return DatabaseMeta.findDatabase( databases, name ); } return DatabaseMeta.findDatabase( databases, new LongObjectId( id_database ) ); }
public RepositoryDirectory getUserHomeDirectory() throws KettleException { RepositoryDirectory root = new RepositoryDirectory(); root.setObjectId( new LongObjectId( 0L ) ); directoryDelegate.loadRepositoryDirectory( root, root.getObjectId() ); return root; }
public synchronized LongObjectId getNextID( String tableName, String fieldName ) throws KettleException { String counterName = tableName + "." + fieldName; Counter counter = Counters.getInstance().getCounter( counterName ); if ( counter == null ) { LongObjectId id = getNextTableID( tableName, fieldName ); counter = new Counter( id.longValue() ); Counters.getInstance().setCounter( counterName, counter ); return new LongObjectId( counter.next() ); } else { return new LongObjectId( counter.next() ); } }
public KDBRMetaStoreElementType parseElementType( String namespace, ObjectId namespaceId, RowMetaAndData elementTypeRow ) throws KettleValueException { Long id = elementTypeRow.getInteger( KettleDatabaseRepository.FIELD_ELEMENT_TYPE_ID_ELEMENT_TYPE ); String name = elementTypeRow.getString( KettleDatabaseRepository.FIELD_ELEMENT_TYPE_NAME, null ); String description = elementTypeRow.getString( KettleDatabaseRepository.FIELD_ELEMENT_TYPE_DESCRIPTION, null ); KDBRMetaStoreElementType type = new KDBRMetaStoreElementType( this, namespace, namespaceId, name, description ); type.setId( new LongObjectId( id ) ); return type; }
@Override public DatabaseMeta getTestObject() { DatabaseMeta db = new DatabaseMeta(); db.setObjectId( new LongObjectId( rand.nextInt( Integer.MAX_VALUE ) ) ); db.setName( UUID.randomUUID().toString() ); db.setHostname( UUID.randomUUID().toString() ); db.setUsername( UUID.randomUUID().toString() ); db.setPassword( UUID.randomUUID().toString() ); return db; }
@Override public IMetaStoreElement getElement( String namespace, IMetaStoreElementType elementType, String elementId ) throws MetaStoreException { try { RowMetaAndData elementRow = delegate.getElement( new LongObjectId( new StringObjectId( elementId ) ) ); if ( elementRow == null ) { return null; } return delegate.parseElement( elementType, elementRow ); } catch ( Exception e ) { throw new MetaStoreException( "Unable to get element", e ); } }
public void addValue( ValueMetaInterface valueMeta, Object valueData ) { if ( valueMeta.isInteger() && ( valueData instanceof ObjectId ) ) { valueData = new LongObjectId( (ObjectId) valueData ).longValue(); } data = RowDataUtil.addValueData( data, rowMeta.size(), valueData ); rowMeta.addValueMeta( valueMeta ); }
@Override public DatabaseMeta loadDatabaseMetaFromStepAttribute( ObjectId id_step, String code, List<DatabaseMeta> databases ) throws KettleException { long id_database = getStepAttributeInteger( id_step, code ); if ( id_database <= 0 ) { return null; } return DatabaseMeta.findDatabase( databases, new LongObjectId( id_database ) ); }
@Override public void saveDatabaseMetaStepAttribute( ObjectId id_transformation, ObjectId id_step, String code, DatabaseMeta database ) throws KettleException { ObjectId id = null; if ( database != null ) { id = database.getObjectId(); Long id_database = id == null ? Long.valueOf( -1L ) : new LongObjectId( id ).longValue(); saveStepAttribute( id_transformation, id_step, code, id_database ); } }
public synchronized ObjectId getRootDirectoryID() throws KettleException { RowMetaAndData result = connectionDelegate.getOneRow( "SELECT " + quote( KettleDatabaseRepository.FIELD_DIRECTORY_ID_DIRECTORY ) + " FROM " + quoteTable( KettleDatabaseRepository.TABLE_R_DIRECTORY ) + " WHERE " + quote( KettleDatabaseRepository.FIELD_DIRECTORY_ID_DIRECTORY_PARENT ) + " = 0" ); if ( result != null && result.isNumeric( 0 ) ) { return new LongObjectId( result.getInteger( 0, -1 ) ); } return null; }
private KDBRMetaStoreAttribute parseAttribute( ObjectId elementId, RowMetaAndData attributeRow ) throws KettleException { try { Long attributeId = attributeRow.getInteger( KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_ID_ELEMENT_ATTRIBUTE ); String key = attributeRow.getString( KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_KEY, null ); String value = attributeRow.getString( KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_VALUE, null ); Object object = parseAttributeValue( value ); KDBRMetaStoreAttribute attribute = new KDBRMetaStoreAttribute( this, key, object ); attribute.setObjectId( new LongObjectId( attributeId ) ); return attribute; } catch ( Exception e ) { throw new KettleException( "Unable to parse attribute from attribute row: " + attributeRow.toString(), e ); } }
@Override public DatabaseMeta loadDatabaseMetaFromJobEntryAttribute( ObjectId id_jobentry, String nameCode, int nr, String idCode, List<DatabaseMeta> databases ) throws KettleException { long id_database = getJobEntryAttributeInteger( id_jobentry, nr, idCode ); if ( id_database <= 0 ) { String name = getJobEntryAttributeString( id_jobentry, nr, nameCode ); if ( name == null ) { return null; } return DatabaseMeta.findDatabase( databases, name ); } return DatabaseMeta.findDatabase( databases, new LongObjectId( id_database ) ); }
public synchronized LongObjectId getIDWithValue( String tablename, String idfield, String lookupfield, String value ) throws KettleException { RowMetaAndData par = new RowMetaAndData(); par.addValue( new ValueMetaString( "value" ), value ); RowMetaAndData result = getOneRow( "SELECT " + idfield + " FROM " + tablename + " WHERE " + lookupfield + " = ?", 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; }