use of org.pentaho.platform.repository.runtime.RuntimeRepository 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();
}
use of org.pentaho.platform.repository.runtime.RuntimeRepository 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();
}
}
use of org.pentaho.platform.repository.runtime.RuntimeRepository 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));
}
}
use of org.pentaho.platform.repository.runtime.RuntimeRepository in project pentaho-platform by pentaho.
the class RuntimeRepositoryTest method doReadOnlyTest.
@SuppressWarnings("unused")
private void doReadOnlyTest(String elementId) {
// $NON-NLS-1$
info(Messages.getInstance().getString("RUNTIMEREPOTEST.USER_TESTINGREADONLY"));
HibernateUtil.beginTransaction();
try {
IRuntimeRepository repo = new RuntimeRepository();
repo.setSession(getPentahoSession());
RuntimeElement baseElement = (RuntimeElement) repo.loadElementById(elementId, null);
// $NON-NLS-1$
info(Messages.getInstance().getString("RUNTIMEREPOTEST.USER_SETTINGELEMENTTOREADONLY"));
baseElement.setReadOnly(true);
} finally {
HibernateUtil.commitTransaction();
}
// Now, the element is read-only.
// Flush the session and re-load the element to
// test the "loaded" methods.
HibernateUtil.flushSession();
HibernateUtil.clear();
// Now, reload the element.
HibernateUtil.beginTransaction();
try {
// $NON-NLS-1$
info(Messages.getInstance().getString("RUNTIMEREPOTEST.USER_LOADINGREADONLY"));
IRuntimeRepository repo = new RuntimeRepository();
repo.setSession(getPentahoSession());
RuntimeElement baseElement = (RuntimeElement) repo.loadElementById(elementId, null);
boolean caughtException = false;
try {
// $NON-NLS-1$
info(Messages.getInstance().getString("RUNTIMEREPOTEST.USER_TRYINGSETSTRINGPROPERTY"));
// $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"));
} catch (IllegalStateException ex) {
caughtException = true;
// $NON-NLS-1$
info(Messages.getInstance().getString("RUNTIMEREPOTEST.USER_EXCEPTIONTRIPPED"));
}
assertTrue(// $NON-NLS-1$
Messages.getInstance().getErrorString("RUNTIMEREPOTEST.ERROR_0001_EXCEPTIONNOTTRIPPED"), caughtException);
caughtException = false;
try {
// $NON-NLS-1$
info(Messages.getInstance().getString("RUNTIMEREPOTEST.USER_TRYINGSETPARENTTYPE"));
// $NON-NLS-1$
baseElement.setParentType(Messages.getInstance().getString("RUNTIMEREPOTEST.CREATE_PARENT_TYPE"));
} catch (IllegalStateException ex) {
caughtException = true;
// $NON-NLS-1$
info(Messages.getInstance().getString("RUNTIMEREPOTEST.USER_EXCEPTIONTRIPPED"));
}
assertTrue(// $NON-NLS-1$
Messages.getInstance().getErrorString("RUNTIMEREPOTEST.ERROR_0001_EXCEPTIONNOTTRIPPED"), caughtException);
} finally {
HibernateUtil.commitTransaction();
}
}
use of org.pentaho.platform.repository.runtime.RuntimeRepository in project pentaho-platform by pentaho.
the class RuntimeRepositoryTest method createRuntimeElement.
@SuppressWarnings("unused")
private RuntimeElement createRuntimeElement() {
IRuntimeRepository repo = new RuntimeRepository();
repo.setSession(getPentahoSession());
RuntimeElement ele = null;
ele = (RuntimeElement) // $NON-NLS-1$
repo.newRuntimeElement(// $NON-NLS-1$
Messages.getInstance().getString("RUNTIMEREPOTEST.CREATE_PARENT"), Messages.getInstance().getString("RUNTIMEREPOTEST.CREATE_PARENT_TYPE"), // $NON-NLS-1$
false);
try {
assertNotNull(ele);
// $NON-NLS-1$
info(Messages.getInstance().getString("RUNTIMEREPOTEST.DEBUG_INSTANCE_ID") + ele.getInstanceId());
// $NON-NLS-1$
ele.setSolutionId(Messages.getInstance().getString("RUNTIMEREPOTEST.SALES_SOLUTION"));
ele.setStringProperty(Messages.getInstance().getString("RUNTIMEREPOTEST.SHORT_STRING_KEY"), // $NON-NLS-1$
Messages.getInstance().getString(// $NON-NLS-1$
"RUNTIMEREPOTEST.SHORT_STRING_VALUE"));
// Get a Long String to Store...
ele.setStringProperty(Messages.getInstance().getString("RUNTIMEREPOTEST.LONG_STRING_KEY"), // $NON-NLS-1$
longString.toString());
// $NON-NLS-1$
ele.setDateProperty(Messages.getInstance().getString("RUNTIMEREPOTEST.DATE_KEY"), new Date());
// $NON-NLS-1$
ele.setBigDecimalProperty(Messages.getInstance().getString("RUNTIMEREPOTEST.DECIMAL_KEY"), bdProperty);
List myList = new ArrayList();
// $NON-NLS-1$
myList.add(Messages.getInstance().getString("RUNTIMEREPOTEST.LIST_ELEMENT_STRING"));
// $NON-NLS-1$
myList.add(new BigDecimal("1283764.1294839483"));
myList.add(new Date());
// $NON-NLS-1$
ele.setListProperty(Messages.getInstance().getString("RUNTIMEREPOTEST.LIST_ELEMENT_KEY"), myList);
} finally {
HibernateUtil.commitTransaction();
}
return ele;
}
Aggregations