Search in sources :

Example 31 with LongObjectId

use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositoryMetaStoreDelegate method parseElementType.

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;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) LongObjectId(org.pentaho.di.repository.LongObjectId) KDBRMetaStoreElementType(org.pentaho.di.repository.kdr.delegates.metastore.KDBRMetaStoreElementType)

Example 32 with LongObjectId

use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.

the class KettleDatabaseRepository method saveConditionStepAttribute.

/**
 * This method saves the object ID of the condition object (if not null) in the step attributes
 *
 * @param id_step
 * @param code
 * @param condition
 */
public void saveConditionStepAttribute(ObjectId id_transformation, ObjectId id_step, String code, Condition condition) throws KettleException {
    ObjectId id = null;
    if (condition != null) {
        id = saveCondition(condition);
        Long id_condition = id == null ? Long.valueOf(-1L) : new LongObjectId(id).longValue();
        saveStepAttribute(id_transformation, id_step, code, id_condition);
        insertTransStepCondition(id_transformation, id_step, condition.getObjectId());
    }
}
Also used : LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) LongObjectId(org.pentaho.di.repository.LongObjectId)

Example 33 with LongObjectId

use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositoryCreationHelper method updateJobEntryTypes.

/**
 * Update the list in R_JOBENTRY_TYPE
 *
 * @param create
 *
 * @exception KettleException
 *              if something went wrong during the update.
 */
public void updateJobEntryTypes(List<String> statements, boolean dryrun, boolean create) throws KettleException {
    synchronized (repository) {
        // We should only do an update if something has changed...
        PluginRegistry registry = PluginRegistry.getInstance();
        List<PluginInterface> jobPlugins = registry.getPlugins(JobEntryPluginType.class);
        for (int i = 0; i < jobPlugins.size(); i++) {
            PluginInterface jobPlugin = jobPlugins.get(i);
            String type_desc = jobPlugin.getIds()[0];
            String type_desc_long = jobPlugin.getName();
            ObjectId id = null;
            if (!create) {
                id = repository.jobEntryDelegate.getJobEntryTypeID(type_desc);
            }
            if (id == null) {
                // Not found, we need to add this one...
                // We need to add this one ...
                id = new LongObjectId(i + 1);
                if (!create) {
                    id = repository.connectionDelegate.getNextJobEntryTypeID();
                }
                RowMetaAndData table = new RowMetaAndData();
                table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_TYPE_ID_JOBENTRY_TYPE), id);
                table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_JOBENTRY_TYPE_CODE), type_desc);
                table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_JOBENTRY_TYPE_DESCRIPTION), type_desc_long);
                if (dryrun) {
                    String sql = database.getSQLOutput(null, KettleDatabaseRepository.TABLE_R_JOBENTRY_TYPE, table.getRowMeta(), table.getData(), null);
                    statements.add(sql);
                } else {
                    database.prepareInsert(table.getRowMeta(), null, KettleDatabaseRepository.TABLE_R_JOBENTRY_TYPE);
                    database.setValuesInsert(table);
                    database.insertRow();
                    database.closeInsert();
                }
            }
        }
    }
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) LongObjectId(org.pentaho.di.repository.LongObjectId)

Example 34 with LongObjectId

use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositoryCreationHelper method updateDatabaseTypes.

/**
 * Update the list in R_DATABASE_TYPE using the database plugin entries
 *
 * @throws KettleException
 *           if the update didn't go as planned.
 */
public List<String> updateDatabaseTypes(List<String> statements, boolean dryrun, boolean create) throws KettleException {
    synchronized (repository) {
        // We should only do an update if something has changed...
        // 
        List<PluginInterface> plugins = pluginRegistry.getPlugins(DatabasePluginType.class);
        for (int i = 0; i < plugins.size(); i++) {
            PluginInterface plugin = plugins.get(i);
            ObjectId id = null;
            if (!create) {
                id = repository.databaseDelegate.getDatabaseTypeID(plugin.getIds()[0]);
            }
            if (id == null) {
                // Not found, we need to add this one...
                // We need to add this one ...
                id = new LongObjectId(i + 1);
                if (!create) {
                    id = repository.connectionDelegate.getNextDatabaseTypeID();
                }
                RowMetaAndData table = new RowMetaAndData();
                table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DATABASE_TYPE_ID_DATABASE_TYPE), id);
                table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_TYPE_CODE), plugin.getIds()[0]);
                table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_TYPE_DESCRIPTION), plugin.getName());
                if (dryrun) {
                    String sql = database.getSQLOutput(null, KettleDatabaseRepository.TABLE_R_DATABASE_TYPE, table.getRowMeta(), table.getData(), null);
                    statements.add(sql);
                } else {
                    database.prepareInsert(table.getRowMeta(), null, KettleDatabaseRepository.TABLE_R_DATABASE_TYPE);
                    database.setValuesInsert(table);
                    database.insertRow();
                    database.closeInsert();
                }
            }
        }
    }
    return statements;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) LongObjectId(org.pentaho.di.repository.LongObjectId) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString)

Example 35 with LongObjectId

use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.

the class MemoryRepository method saveDatabaseMetaJobEntryAttribute.

@Override
public void saveDatabaseMetaJobEntryAttribute(ObjectId id_job, ObjectId id_jobentry, int nr, String nameCode, String idCode, 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();
        // Save both the ID and the name of the database connection...
        // 
        saveJobEntryAttribute(id_job, id_jobentry, nr, idCode, id_database);
        saveJobEntryAttribute(id_job, id_jobentry, nr, nameCode, id_database);
        insertJobEntryDatabase(id_job, id_jobentry, id);
    }
}
Also used : StringObjectId(org.pentaho.di.repository.StringObjectId) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) LongObjectId(org.pentaho.di.repository.LongObjectId)

Aggregations

LongObjectId (org.pentaho.di.repository.LongObjectId)81 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)54 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)36 ObjectId (org.pentaho.di.repository.ObjectId)30 KettleException (org.pentaho.di.core.exception.KettleException)18 Test (org.junit.Test)17 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)17 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)14 Matchers.anyString (org.mockito.Matchers.anyString)10 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)10 ArrayList (java.util.ArrayList)9 RepositoryDirectory (org.pentaho.di.repository.RepositoryDirectory)9 RepositoryObject (org.pentaho.di.repository.RepositoryObject)8 MetaStoreDependenciesExistsException (org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException)8 MetaStoreElementExistException (org.pentaho.metastore.api.exceptions.MetaStoreElementExistException)8 MetaStoreElementTypeExistsException (org.pentaho.metastore.api.exceptions.MetaStoreElementTypeExistsException)8 MetaStoreNamespaceExistsException (org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException)8 SimpleLoggingObject (org.pentaho.di.core.logging.SimpleLoggingObject)7 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)7 StringObjectId (org.pentaho.di.repository.StringObjectId)7