use of org.pentaho.agilebi.modeler.util.SpoonModelerMessages in project data-access by pentaho.
the class SerializeMultiTableServiceIT method testSerialize.
@Test
public void testSerialize() throws Exception {
if (ModelerMessagesHolder.getMessages() == null) {
ModelerMessagesHolder.setMessages(new SpoonModelerMessages());
}
try {
KettleEnvironment.init();
Props.init(Props.TYPE_PROPERTIES_EMPTY);
} catch (Exception e) {
// may already be initialized by another test
}
login("suzy", "", false);
String solutionStorage = AgileHelper.getDatasourceSolutionStorage();
String path = solutionStorage + RepositoryFile.SEPARATOR + "resources" + RepositoryFile.SEPARATOR + "metadata" + // $NON-NLS-1$ //$NON-NLS-2$
RepositoryFile.SEPARATOR;
String olapPath = null;
IApplicationContext appContext = PentahoSystem.getApplicationContext();
if (appContext != null) {
path = PentahoSystem.getApplicationContext().getSolutionPath(path);
olapPath = PentahoSystem.getApplicationContext().getSolutionPath(// $NON-NLS-1$ //$NON-NLS-2$
"system" + RepositoryFile.SEPARATOR + "olap" + RepositoryFile.SEPARATOR);
}
// $NON-NLS-1$
File olap1 = new File(olapPath + "datasources.xml");
// $NON-NLS-1$
File olap2 = new File(olapPath + "tmp_datasources.xml");
FileUtils.copyFile(olap1, olap2);
DatabaseMeta database = getDatabaseMeta();
MultiTableModelerSource multiTable = new MultiTableModelerSource(database, getSchema(), database.getName(), Arrays.asList("CUSTOMERS", "PRODUCTS", "CUSTOMERNAME", "PRODUCTCODE"));
Domain domain = multiTable.generateDomain();
List<OlapDimension> olapDimensions = new ArrayList<OlapDimension>();
OlapDimension dimension = new OlapDimension();
// $NON-NLS-1$
dimension.setName("test");
dimension.setTimeDimension(false);
olapDimensions.add(dimension);
// $NON-NLS-1$
domain.getLogicalModels().get(0).setProperty("olap_dimensions", olapDimensions);
ModelerService service = new ModelerService();
// $NON-NLS-1$
service.serializeModels(domain, "test_file");
Assert.assertEquals((String) domain.getLogicalModels().get(0).getProperty("MondrianCatalogRef"), "SampleData");
}
use of org.pentaho.agilebi.modeler.util.SpoonModelerMessages in project data-access by pentaho.
the class SerializeServiceIT method testSerialize.
@Test
public void testSerialize() throws Exception {
if (ModelerMessagesHolder.getMessages() == null) {
ModelerMessagesHolder.setMessages(new SpoonModelerMessages());
}
try {
KettleEnvironment.init();
Props.init(Props.TYPE_PROPERTIES_EMPTY);
} catch (Exception e) {
// may already be initialized by another test
}
login("suzy", "", false);
String solutionStorage = AgileHelper.getDatasourceSolutionStorage();
String path = solutionStorage + RepositoryFile.SEPARATOR + "resources" + RepositoryFile.SEPARATOR + "metadata" + // $NON-NLS-1$ //$NON-NLS-2$
RepositoryFile.SEPARATOR;
String olapPath = null;
IApplicationContext appContext = PentahoSystem.getApplicationContext();
if (appContext != null) {
path = PentahoSystem.getApplicationContext().getSolutionPath(path);
olapPath = PentahoSystem.getApplicationContext().getSolutionPath(// $NON-NLS-1$ //$NON-NLS-2$
"system" + RepositoryFile.SEPARATOR + "olap" + RepositoryFile.SEPARATOR);
}
// $NON-NLS-1$
File olap1 = new File(olapPath + "datasources.xml");
// $NON-NLS-1$
File olap2 = new File(olapPath + "tmp_datasources.xml");
FileUtils.copyFile(olap1, olap2);
Domain domain = generateModel();
ModelerService service = new ModelerService();
ModelerWorkspace model = new ModelerWorkspace(new GwtModelerWorkspaceHelper());
model.setModelName("ORDERS");
model.setDomain(domain);
model.getWorkspaceHelper().populateDomain(model);
// $NON-NLS-1$
service.serializeModels(domain, "test_file");
Assert.assertEquals(domain.getLogicalModels().get(1).getProperty("MondrianCatalogRef"), model.getModelName());
}
Aggregations