Search in sources :

Example 26 with LongObjectId

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

the class KettleDatabaseRepositoryJobDelegate method loadJobHopMeta.

public JobHopMeta loadJobHopMeta(ObjectId id_job_hop, List<JobEntryCopy> jobcopies) throws KettleException {
    JobHopMeta jobHopMeta = new JobHopMeta();
    try {
        RowMetaAndData r = getJobHop(id_job_hop);
        if (r != null) {
            long id_jobentry_copy_from = r.getInteger("ID_JOBENTRY_COPY_FROM", -1L);
            long id_jobentry_copy_to = r.getInteger("ID_JOBENTRY_COPY_TO", -1L);
            jobHopMeta.setEnabled(r.getBoolean("ENABLED", true));
            jobHopMeta.setEvaluation(r.getBoolean("EVALUATION", true));
            jobHopMeta.setConditional();
            if (r.getBoolean("UNCONDITIONAL", !jobHopMeta.getEvaluation())) {
                jobHopMeta.setUnconditional();
            }
            jobHopMeta.setFromEntry(JobMeta.findJobEntryCopy(jobcopies, new LongObjectId(id_jobentry_copy_from)));
            jobHopMeta.setToEntry(JobMeta.findJobEntryCopy(jobcopies, new LongObjectId(id_jobentry_copy_to)));
            return jobHopMeta;
        } else {
            throw new KettleException("Unable to find job hop with ID : " + id_job_hop);
        }
    } catch (KettleDatabaseException dbe) {
        throw new KettleException(BaseMessages.getString(PKG, "JobHopMeta.Exception.UnableToLoadHopInfoRep", "" + id_job_hop), dbe);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) JobHopMeta(org.pentaho.di.job.JobHopMeta) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) LongObjectId(org.pentaho.di.repository.LongObjectId)

Example 27 with LongObjectId

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

the class KettleDatabaseRepositoryJobDelegate method getJobsWithIDList.

public String[] getJobsWithIDList(ObjectId[] ids) throws KettleException {
    String[] jobsList = new String[ids.length];
    for (int i = 0; i < ids.length; i++) {
        ObjectId id_job = ids[i];
        if (id_job != null) {
            RowMetaAndData transRow = getJob(id_job);
            if (transRow != null) {
                String jobName = transRow.getString(KettleDatabaseRepository.FIELD_JOB_NAME, "<name not found>");
                long id_directory = transRow.getInteger(KettleDatabaseRepository.FIELD_JOB_ID_DIRECTORY, -1L);
                RepositoryDirectoryInterface dir = repository.loadRepositoryDirectoryTree().findDirectory(new LongObjectId(id_directory));
                jobsList[i] = dir.getPathObjectCombination(jobName);
            }
        }
    }
    return jobsList;
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) LongObjectId(org.pentaho.di.repository.LongObjectId)

Example 28 with LongObjectId

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

the class KettleDatabaseRepositoryJobDelegate method getJobsWithIDList.

public String[] getJobsWithIDList(List<Object[]> list, RowMetaInterface rowMeta) throws KettleException {
    String[] jobList = new String[list.size()];
    for (int i = 0; i < list.size(); i++) {
        long id_job = rowMeta.getInteger(list.get(i), quote(KettleDatabaseRepository.FIELD_JOB_ID_JOB), -1L);
        if (id_job > 0) {
            RowMetaAndData jobRow = getJob(new LongObjectId(id_job));
            if (jobRow != null) {
                String jobName = jobRow.getString(KettleDatabaseRepository.FIELD_JOB_NAME, "<name not found>");
                long id_directory = jobRow.getInteger(KettleDatabaseRepository.FIELD_JOB_ID_DIRECTORY, -1L);
                RepositoryDirectoryInterface dir = // always
                repository.loadRepositoryDirectoryTree().findDirectory(new LongObjectId(id_directory));
                // reload the
                // directory
                // tree!
                jobList[i] = dir.getPathObjectCombination(jobName);
            }
        }
    }
    return jobList;
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) LongObjectId(org.pentaho.di.repository.LongObjectId)

Example 29 with LongObjectId

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

the class KettleDatabaseRepositoryJobEntryDelegate method loadJobEntryCopy.

/**
 * Load the chef graphical entry from repository We load type, name & description if no entry can be found.
 *
 * @param log
 *          the logging channel
 * @param rep
 *          the Repository
 * @param jobId
 *          The job ID
 * @param jobEntryCopyId
 *          The jobentry copy ID
 * @param jobentries
 *          A list with all jobentries
 * @param databases
 *          A list with all defined databases
 */
public JobEntryCopy loadJobEntryCopy(ObjectId jobId, ObjectId jobEntryCopyId, List<JobEntryInterface> jobentries, List<DatabaseMeta> databases, List<SlaveServer> slaveServers, String jobname) throws KettleException {
    JobEntryCopy jobEntryCopy = new JobEntryCopy();
    try {
        jobEntryCopy.setObjectId(jobEntryCopyId);
        // Handle GUI information: nr, location, ...
        RowMetaAndData r = getJobEntryCopy(jobEntryCopyId);
        if (r != null) {
            // These are the jobentry_copy fields...
            // 
            ObjectId jobEntryId = new LongObjectId(r.getInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_ID_JOBENTRY, 0));
            ObjectId jobEntryTypeId = new LongObjectId(r.getInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_ID_JOBENTRY_TYPE, 0));
            jobEntryCopy.setNr((int) r.getInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_NR, 0));
            int locx = (int) r.getInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_GUI_LOCATION_X, 0);
            int locy = (int) r.getInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_GUI_LOCATION_Y, 0);
            boolean isdrawn = r.getBoolean(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_GUI_DRAW, false);
            boolean isparallel = r.getBoolean(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_PARALLEL, false);
            // Do we have the jobentry already?
            // 
            jobEntryCopy.setEntry(JobMeta.findJobEntry(jobentries, jobEntryId));
            if (jobEntryCopy.getEntry() == null) {
                // What type of jobentry do we load now?
                // Get the jobentry type code
                // 
                RowMetaAndData rt = getJobEntryType(new LongObjectId(jobEntryTypeId));
                if (rt != null) {
                    String jet_code = rt.getString(KettleDatabaseRepository.FIELD_JOBENTRY_TYPE_CODE, null);
                    JobEntryInterface jobEntry = null;
                    PluginRegistry registry = PluginRegistry.getInstance();
                    PluginInterface jobPlugin = registry.findPluginWithId(JobEntryPluginType.class, jet_code);
                    if (jobPlugin == null) {
                        jobEntry = new MissingEntry(jobname, jet_code);
                    } else {
                        jobEntry = (JobEntryInterface) registry.loadClass(jobPlugin);
                    }
                    if (jobEntry != null) {
                        jobEntryCopy.setEntry(jobEntry);
                        // 
                        if (jobEntry instanceof JobEntryBase) {
                            loadJobEntryBase((JobEntryBase) jobEntry, jobEntryId, databases, slaveServers);
                            ((JobEntryBase) jobEntry).setAttributesMap(loadJobEntryAttributesMap(jobId, jobEntryId));
                        }
                        compatibleJobEntryLoadRep(jobEntry, repository, jobEntryTypeId, databases, slaveServers);
                        jobEntry.loadRep(repository, repository.metaStore, jobEntryId, databases, slaveServers);
                        jobEntryCopy.getEntry().setObjectId(jobEntryId);
                        jobentries.add(jobEntryCopy.getEntry());
                    } else {
                        throw new KettleException("JobEntryLoader was unable to find Job Entry Plugin with description [" + jet_code + "].");
                    }
                } else {
                    throw new KettleException("Unable to find Job Entry Type with id=" + jobEntryTypeId + " in the repository");
                }
            }
            jobEntryCopy.setLocation(locx, locy);
            jobEntryCopy.setDrawn(isdrawn);
            jobEntryCopy.setLaunchingInParallel(isparallel);
            return jobEntryCopy;
        } else {
            throw new KettleException("Unable to find job entry copy in repository with id_jobentry_copy=" + jobEntryCopyId);
        }
    } catch (KettleDatabaseException dbe) {
        throw new KettleException("Unable to load job entry copy from repository with id_jobentry_copy=" + jobEntryCopyId, dbe);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) LongObjectId(org.pentaho.di.repository.LongObjectId) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) MissingEntry(org.pentaho.di.job.entries.missing.MissingEntry) JobEntryBase(org.pentaho.di.job.entry.JobEntryBase) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry)

Example 30 with LongObjectId

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

the class KettleDatabaseRepositoryMetaStoreDelegate method parseElement.

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

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