Search in sources :

Example 1 with IRuntimeRepository

use of org.pentaho.platform.api.repository.IRuntimeRepository in project pentaho-platform by pentaho.

the class RuntimeRepositoryTest method cleanupElement.

@SuppressWarnings("unused")
private void cleanupElement(String elementId) {
    HibernateUtil.beginTransaction();
    IRuntimeRepository repo = new RuntimeRepository();
    repo.setSession(getPentahoSession());
    RuntimeElement re = (RuntimeElement) repo.loadElementById(elementId, null);
    HibernateUtil.makeTransient(re);
    HibernateUtil.commitTransaction();
    HibernateUtil.flushSession();
    HibernateUtil.clear();
}
Also used : IRuntimeRepository(org.pentaho.platform.api.repository.IRuntimeRepository) RuntimeElement(org.pentaho.platform.repository.runtime.RuntimeElement) IRuntimeRepository(org.pentaho.platform.api.repository.IRuntimeRepository) RuntimeRepository(org.pentaho.platform.repository.runtime.RuntimeRepository)

Example 2 with IRuntimeRepository

use of org.pentaho.platform.api.repository.IRuntimeRepository in project pentaho-platform by pentaho.

the class RuntimeRepositoryTest method modifyAdd.

@SuppressWarnings("unused")
private void modifyAdd(RuntimeElement baseElement) {
    HibernateUtil.beginTransaction();
    try {
        IRuntimeRepository repo = new RuntimeRepository();
        repo.setSession(getPentahoSession());
        // $NON-NLS-1$
        baseElement.setStringProperty(// $NON-NLS-1$
        Messages.getInstance().getString("RUNTIMEREPOTEST.MODIFY_NEW_STRING_KEY"), // $NON-NLS-1$
        Messages.getInstance().getString("RUNTIMEREPOTEST.MODIFY_STRING_VALUE"));
    } finally {
        HibernateUtil.commitTransaction();
    }
}
Also used : IRuntimeRepository(org.pentaho.platform.api.repository.IRuntimeRepository) IRuntimeRepository(org.pentaho.platform.api.repository.IRuntimeRepository) RuntimeRepository(org.pentaho.platform.repository.runtime.RuntimeRepository)

Example 3 with IRuntimeRepository

use of org.pentaho.platform.api.repository.IRuntimeRepository in project pentaho-platform by pentaho.

the class RuntimeRepositoryTest method readElementTest.

@SuppressWarnings("unused")
private void readElementTest(String instanceId) {
    HibernateUtil.beginTransaction();
    IRuntimeRepository repo = new RuntimeRepository();
    repo.setSession(getPentahoSession());
    RuntimeElement re = (RuntimeElement) repo.loadElementById(instanceId, null);
    // $NON-NLS-1$
    checkValue(Messages.getInstance().getString("RUNTIMEREPOTEST.SALES_SOLUTION"), re.getSolutionId());
    checkValue(longString.toString(), re.getStringProperty(Messages.getInstance().getString(// $NON-NLS-1$
    "RUNTIMEREPOTEST.LONG_STRING_KEY")));
    checkValue(Messages.getInstance().getString("RUNTIMEREPOTEST.SHORT_STRING_VALUE"), re.getStringProperty(// $NON-NLS-1$
    Messages.getInstance().getString(// $NON-NLS-1$
    "RUNTIMEREPOTEST.SHORT_STRING_KEY")));
    checkValue(bdProperty, re.getBigDecimalProperty(Messages.getInstance().getString(// $NON-NLS-1$
    "RUNTIMEREPOTEST.DECIMAL_KEY")));
    String xml = re.toXML();
    info(xml);
    Set namesSet = re.getParameterNames();
    Iterator it = namesSet.iterator();
    String pName, pType;
    while (it.hasNext()) {
        pName = (String) it.next();
        pType = re.getParameterType(pName);
        // $NON-NLS-1$
        info(Messages.getInstance().getString("RUNTIMEREPOTEST.DEBUG_NAME_TYPE", pName, pType));
    }
}
Also used : IRuntimeRepository(org.pentaho.platform.api.repository.IRuntimeRepository) RuntimeElement(org.pentaho.platform.repository.runtime.RuntimeElement) Set(java.util.Set) Iterator(java.util.Iterator) IRuntimeRepository(org.pentaho.platform.api.repository.IRuntimeRepository) RuntimeRepository(org.pentaho.platform.repository.runtime.RuntimeRepository)

Example 4 with IRuntimeRepository

use of org.pentaho.platform.api.repository.IRuntimeRepository in project pentaho-platform by pentaho.

the class RuntimeContext method createChild.

private IRuntimeElement createChild(boolean persisted) {
    IRuntimeElement childRuntimeData = null;
    IRuntimeRepository runtimeRepository = PentahoSystem.get(IRuntimeRepository.class, session);
    // the runtime repository is optional
    if (runtimeRepository != null) {
        runtimeRepository.setLoggingLevel(loggingLevel);
        // $NON-NLS-1$
        childRuntimeData = runtimeRepository.newRuntimeElement(instanceId, "instance", !persisted);
        String childInstanceId = childRuntimeData.getInstanceId();
        // audit the creation of this against the parent instance
        AuditHelper.audit(instanceId, session.getName(), getActionName(), getObjectName(), processId, MessageTypes.INSTANCE_START, childInstanceId, "", 0, // $NON-NLS-1$
        this);
    }
    return childRuntimeData;
}
Also used : IRuntimeRepository(org.pentaho.platform.api.repository.IRuntimeRepository) IRuntimeElement(org.pentaho.platform.api.repository.IRuntimeElement)

Example 5 with IRuntimeRepository

use of org.pentaho.platform.api.repository.IRuntimeRepository in project pentaho-platform by pentaho.

the class SolutionEngine method execute.

protected IRuntimeContext execute(final String actionPath, final String processId, final boolean async, final boolean instanceEnds, String instanceId, final boolean isPersisted, final Map parameterProviderMap, final IOutputHandler outputHandler, final IActionCompleteListener pListener, final IPentahoUrlFactory urlFactory, final List messages, final String actionSequenceXML) {
    this.persisted = isPersisted;
    setlistener(pListener);
    setSession(session);
    setMessages(messages);
    auditStart(actionPath, instanceId);
    if (!checkParameters(actionPath, processId)) {
        return null;
    }
    session.setProcessId(processId);
    session.setActionName(actionPath);
    // create the runtime context object for this operation
    if (debug) {
        // $NON-NLS-1$
        debug(Messages.getInstance().getString("SolutionEngine.DEBUG_GETTING_RUNTIME_CONTEXT"));
    }
    boolean newInstance = instanceId == null;
    IRuntimeRepository runtimeRepository = null;
    if (PentahoSystem.getObjectFactory().objectDefined(IRuntimeRepository.class.getSimpleName())) {
        runtimeRepository = PentahoSystem.get(IRuntimeRepository.class, session);
    }
    IRuntimeElement runtimeData;
    if (runtimeRepository == null) {
        String id = UUIDUtil.getUUIDAsString();
        runtimeData = new SimpleRuntimeElement(id, session.getId(), IParameterProvider.SCOPE_SESSION);
    } else {
        runtimeRepository.setLoggingLevel(loggingLevel);
        if (newInstance) {
            // we need to create runtime data for this execution
            try {
                runtimeData = runtimeRepository.newRuntimeElement(session.getId(), IParameterProvider.SCOPE_SESSION, !persisted);
            } catch (Throwable t) {
                // $NON-NLS-1$
                error(Messages.getInstance().getErrorString("SolutionEngine.ERROR_0008_INVALID_INSTANCE", instanceId), t);
                status = IRuntimeContext.RUNTIME_STATUS_SETUP_FAIL;
                return null;
            }
        } else {
            try {
                runtimeData = runtimeRepository.loadElementById(instanceId, null);
            } catch (Throwable t) {
                // $NON-NLS-1$
                error(Messages.getInstance().getErrorString("SolutionEngine.ERROR_0008_INVALID_INSTANCE", instanceId), t);
                status = IRuntimeContext.RUNTIME_STATUS_SETUP_FAIL;
                return null;
            }
        }
    }
    if (runtimeData == null) {
        // $NON-NLS-1$
        error(Messages.getInstance().getErrorString("SolutionEngine.ERROR_0008_INVALID_INSTANCE", instanceId));
        status = IRuntimeContext.RUNTIME_STATUS_SETUP_FAIL;
        return null;
    }
    createRuntime(runtimeData, actionPath, outputHandler, processId, urlFactory);
    runtime.setLoggingLevel(loggingLevel);
    instanceId = runtime.getInstanceId();
    genLogIdFromInfo(instanceId, SolutionEngine.LOG_NAME, actionPath);
    if (newInstance) {
        // audit the creation of this against the session
        AuditHelper.audit(session.getId(), session.getName(), actionPath, getObjectName(), processId, MessageTypes.INSTANCE_START, instanceId, "", 0, // $NON-NLS-1$
        this);
    }
    /*
     * IRuntimeElement runtimeData; if (instanceId == null) { // we need to create runtime data for this execution try {
     * runtimeRepository.setLoggingLevel(loggingLevel); runtimeData =
     * runtimeRepository.newRuntimeElement(session.getId(), IParameterProvider.SCOPE_SESSION, !persisted);
     * createRuntime(runtimeData, solutionName, outputHandler, processId, urlFactory);
     * runtime.setLoggingLevel(loggingLevel); instanceId = runtime.getInstanceId(); genLogIdFromInfo(instanceId,
     * SolutionEngine.LOG_NAME, sequenceName); // audit the creation of this against the session
     * AuditHelper.audit(session.getId(), session.getName(), sequenceName, getObjectName(), processId,
     * MessageTypes.INSTANCE_START, instanceId, "", 0, this); //$NON-NLS-1$ } catch (Throwable t) {
     * error(Messages.getInstance().getErrorString("SolutionEngine.ERROR_0008_INVALID_INSTANCE", instanceId), t);
     * //$NON-NLS-1$ status = IRuntimeContext.RUNTIME_STATUS_SETUP_FAIL; return null; } } else { try {
     * runtimeRepository.setLoggingLevel(loggingLevel); runtimeData = runtimeRepository.loadElementById(instanceId,
     * null); createRuntime(runtimeData, solutionName, outputHandler, processId, urlFactory);
     * runtime.setLoggingLevel(loggingLevel); instanceId = runtime.getInstanceId(); genLogIdFromInfo(instanceId,
     * SolutionEngine.LOG_NAME, sequenceName); } catch (Throwable t) {
     * error(Messages.getInstance().getErrorString("SolutionEngine.ERROR_0008_INVALID_INSTANCE", instanceId), t);
     * //$NON-NLS-1$ status = IRuntimeContext.RUNTIME_STATUS_SETUP_FAIL; return null; } }
     */
    return executeInternal(actionPath, processId, async, instanceEnds, parameterProviderMap, actionSequenceXML);
}
Also used : IRuntimeRepository(org.pentaho.platform.api.repository.IRuntimeRepository) IRuntimeElement(org.pentaho.platform.api.repository.IRuntimeElement) SimpleRuntimeElement(org.pentaho.platform.engine.services.runtime.SimpleRuntimeElement)

Aggregations

IRuntimeRepository (org.pentaho.platform.api.repository.IRuntimeRepository)8 RuntimeRepository (org.pentaho.platform.repository.runtime.RuntimeRepository)5 RuntimeElement (org.pentaho.platform.repository.runtime.RuntimeElement)4 IRuntimeElement (org.pentaho.platform.api.repository.IRuntimeElement)3 BigDecimal (java.math.BigDecimal)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 List (java.util.List)2 Set (java.util.Set)2 SimpleRuntimeElement (org.pentaho.platform.engine.services.runtime.SimpleRuntimeElement)2 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 IPentahoResultSet (org.pentaho.commons.connection.IPentahoResultSet)1 MemoryResultSet (org.pentaho.commons.connection.memory.MemoryResultSet)1 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)1 SimpleRuntimeRepository (org.pentaho.platform.repository.SimpleRuntimeRepository)1