Search in sources :

Example 11 with FileSystemBackedUnifiedRepository

use of org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository in project pentaho-platform by pentaho.

the class PentahoMetadataDomainRepositoryTest method setUp.

@Before
public void setUp() throws Exception {
    // File tempDir = File.createTempFile("test", "");
    // tempDir.delete();
    // tempDir.mkdir();
    // System.err.println("tempDir = " + tempDir.getAbsolutePath());
    // repository = new FileSystemBackedUnifiedRepository(tempDir);
    // new RepositoryUtils(repository).getFolder("/etc/metadata", true, true, null);
    final IPentahoSession mockSession = Mockito.mock(IPentahoSession.class);
    PentahoSessionHolder.setSession(mockSession);
    repository = new FileSystemBackedUnifiedRepository();
    repository.deleteFile(new RepositoryUtils(repository).getFolder("/etc/metadata", true, true, null).getId(), true, null);
    assertNotNull(new RepositoryUtils(repository).getFolder("/etc/metadata", true, true, null));
    final MockXmiParser xmiParser = new MockXmiParser();
    domainRepository = createDomainRepository(repository, null, xmiParser, null);
    domainRepositorySpy = spy(domainRepository);
    aclNodeHelper = mock(IAclNodeHelper.class);
    doReturn(aclNodeHelper).when(domainRepositorySpy).getAclHelper();
    doNothing().when(aclNodeHelper).removeAclFor(any(RepositoryFile.class));
    when(aclNodeHelper.canAccess(any(RepositoryFile.class), any(EnumSet.class))).thenReturn(true);
    while (domainRepositorySpy.getDomainIds().size() > 0) {
        domainRepositorySpy.removeDomain(domainRepositorySpy.getDomainIds().iterator().next());
    }
}
Also used : RepositoryUtils(org.pentaho.platform.repository2.unified.RepositoryUtils) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) IAclNodeHelper(org.pentaho.platform.api.repository2.unified.IAclNodeHelper) EnumSet(java.util.EnumSet) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) FileSystemBackedUnifiedRepository(org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository) Before(org.junit.Before)

Example 12 with FileSystemBackedUnifiedRepository

use of org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository in project pentaho-platform by pentaho.

the class SolutionImportHandlerNamingIT method init.

@Before
public void init() throws IOException, PlatformInitializationException, PlatformImportException, DomainIdNullException, DomainAlreadyExistsException, DomainStorageException {
    // repository
    File repoDir = new File(tempDir.getAbsolutePath() + REPO_PATH);
    FileUtils.forceMkdir(repoDir);
    FileUtils.cleanDirectory(repoDir);
    repoRoot = repoDir;
    repo = new FileSystemBackedUnifiedRepository();
    repo = Mockito.spy(repo);
    repo.setRootDir(repoRoot);
    // mimeResolver
    final Converter defaultConverter = new StreamConverter();
    final List<IMimeType> solutionMimeList = java.util.Collections.singletonList(MIME_SOLUTION);
    final List<IMimeType> contentMimeList = java.util.Arrays.asList(new IMimeType[] { MIME_PRPT, MIME_XML });
    final List<IMimeType> allMimeTypes = new ArrayList<IMimeType>(solutionMimeList.size() + contentMimeList.size());
    {
        allMimeTypes.addAll(solutionMimeList);
        allMimeTypes.addAll(contentMimeList);
        for (IMimeType mimeType : allMimeTypes) {
            mimeType.setConverter(defaultConverter);
        }
    }
    final IPlatformMimeResolver mimeResolver = new NameBaseMimeResolver();
    for (IMimeType mimeType : allMimeTypes) {
        mimeResolver.addMimeType(mimeType);
    }
    // platform, import handlers
    PentahoSystem.clearObjectFactory();
    microPlatform = new MicroPlatform(getSolutionPath());
    microPlatform.defineInstance(IUnifiedRepository.class, repo);
    microPlatform.defineInstance(IPlatformMimeResolver.class, mimeResolver);
    microPlatform.defineInstance(ISolutionEngine.class, Mockito.mock(SolutionEngine.class));
    microPlatform.defineInstance(IDatasourceMgmtService.class, Mockito.mock(IDatasourceMgmtService.class));
    IRepositoryContentConverterHandler converterHandler = new DefaultRepositoryContentConverterHandler(new HashMap<String, Converter>());
    RepositoryFileImportFileHandler contentImportFileHandler = new RepositoryFileImportFileHandler(contentMimeList);
    contentImportFileHandler.setRepository(repo);
    solutionImportHandler = new SolutionImportHandler(solutionMimeList);
    List<IPlatformImportHandler> handlers = new ArrayList<IPlatformImportHandler>();
    handlers.add(contentImportFileHandler);
    handlers.add(solutionImportHandler);
    PentahoPlatformImporter importer = new PentahoPlatformImporter(handlers, converterHandler);
    importer.setDefaultHandler(contentImportFileHandler);
    importer.setRepositoryImportLogger(new Log4JRepositoryImportLogger());
    microPlatform.defineInstance(IPlatformImporter.class, importer);
    microPlatform.start();
}
Also used : ArrayList(java.util.ArrayList) ISolutionEngine(org.pentaho.platform.api.engine.ISolutionEngine) SolutionEngine(org.pentaho.platform.engine.services.solution.SolutionEngine) IDatasourceMgmtService(org.pentaho.platform.api.repository.datasource.IDatasourceMgmtService) IMimeType(org.pentaho.platform.api.mimetype.IMimeType) IRepositoryContentConverterHandler(org.pentaho.platform.api.repository2.unified.IRepositoryContentConverterHandler) IPlatformMimeResolver(org.pentaho.platform.api.mimetype.IPlatformMimeResolver) Log4JRepositoryImportLogger(org.pentaho.platform.plugin.services.importexport.Log4JRepositoryImportLogger) StreamConverter(org.pentaho.platform.plugin.services.importexport.StreamConverter) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) Converter(org.pentaho.platform.api.repository2.unified.Converter) StreamConverter(org.pentaho.platform.plugin.services.importexport.StreamConverter) File(java.io.File) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) FileSystemBackedUnifiedRepository(org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository) Before(org.junit.Before)

Example 13 with FileSystemBackedUnifiedRepository

use of org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository in project pentaho-platform by pentaho.

the class MondrianCatalogRepositoryHelperIT method testSchemaFilesContainsAnnotatedSchema.

@Test
public void testSchemaFilesContainsAnnotatedSchema() throws Exception {
    FileSystemBackedUnifiedRepository repository = new FileSystemBackedUnifiedRepository(TestResourceLocation.TEST_RESOURCES + "/MondrianCatalogRepositoryHelperTest");
    MondrianCatalogRepositoryHelper helper = new MondrianCatalogRepositoryHelper(repository);
    Map<String, InputStream> schemaFiles = helper.getModrianSchemaFiles("food");
    assertEquals(3, schemaFiles.size());
    assertSchemaFile(TestResourceLocation.TEST_RESOURCES + "/MondrianCatalogRepositoryHelperTest/etc/mondrian/food/schema.xml", schemaFiles.get("schema.xml"));
    assertSchemaFile(TestResourceLocation.TEST_RESOURCES + "/MondrianCatalogRepositoryHelperTest/etc/mondrian/food/annotations.xml", schemaFiles.get("annotations.xml"));
    assertSchemaFile(TestResourceLocation.TEST_RESOURCES + "/MondrianCatalogRepositoryHelperTest/schema.annotated.xml", schemaFiles.get("schema.annotated.xml"));
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) FileSystemBackedUnifiedRepository(org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository) Test(org.junit.Test)

Example 14 with FileSystemBackedUnifiedRepository

use of org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository in project pentaho-platform by pentaho.

the class PentahoSystemPluginManagerIT method init0.

public void init0() {
    microPlatform = new MicroPlatform(solutionPath);
    microPlatform.define(ISolutionEngine.class, SolutionEngine.class);
    microPlatform.define(ISystemConfig.class, SystemConfig.class);
    microPlatform.define(IPluginProvider.class, SystemPathXmlPluginProvider.class);
    microPlatform.define(IPluginResourceLoader.class, PluginResourceLoader.class);
    microPlatform.define(IServiceManager.class, DefaultServiceManager.class, IPentahoDefinableObjectFactory.Scope.GLOBAL);
    microPlatform.define(IUnifiedRepository.class, FileSystemBackedUnifiedRepository.class, IPentahoDefinableObjectFactory.Scope.GLOBAL);
    FileSystemBackedUnifiedRepository repo = (FileSystemBackedUnifiedRepository) PentahoSystem.get(IUnifiedRepository.class);
    repo.setRootDir(new File(TestResourceLocation.TEST_RESOURCES + "/PluginManagerTest"));
    session = new StandaloneSession();
    pluginManager = new PentahoSystemPluginManager();
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) File(java.io.File) FileSystemBackedUnifiedRepository(org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository)

Example 15 with FileSystemBackedUnifiedRepository

use of org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository in project pentaho-platform by pentaho.

the class MetadataQueryComponentIT method setUp.

@Before
public void setUp() throws Exception {
    microPlatform = new MicroPlatform(TestResourceLocation.TEST_RESOURCES + "/solution");
    microPlatform.define(ISolutionEngine.class, SolutionEngine.class);
    microPlatform.define(IMetadataDomainRepository.class, InMemoryMetadataDomainRepository.class, Scope.GLOBAL);
    microPlatform.define("connection-SQL", SQLConnection.class);
    microPlatform.define(IUnifiedRepository.class, FileSystemBackedUnifiedRepository.class, Scope.GLOBAL);
    FileSystemBackedUnifiedRepository repos = (FileSystemBackedUnifiedRepository) PentahoSystem.get(IUnifiedRepository.class);
    repos.setRootDir(new File(TestResourceLocation.TEST_RESOURCES + "/solution"));
    microPlatform.define(IDBDatasourceService.class, JndiDatasourceService.class, Scope.GLOBAL);
    KettleEnvironment.init(false);
    IMetadataDomainRepository repo = PentahoSystem.get(IMetadataDomainRepository.class, null);
    Domain domain = getBasicDomain();
    Domain domain2 = getJdbcDomain();
    Domain domain3 = getJdbcDomain();
    domain3.setId("JDBCDOMAIN2");
    domain3.getLogicalModels().get(0).setProperty("max_rows", new BigDecimal(10));
    Domain domain4 = getBasicDomain();
    ((SqlPhysicalModel) domain4.getPhysicalModels().get(0)).getDatasource().setDialectType("MYSQL");
    Map<String, String> attributes = new HashMap<String, String>();
    attributes.put("QUOTE_ALL_FIELDS", "Y");
    ((SqlPhysicalModel) domain4.getPhysicalModels().get(0)).getDatasource().setAttributes(attributes);
    domain4.setId("MYSQL_DOMAIN");
    repo.storeDomain(domain, true);
    repo.storeDomain(domain2, true);
    repo.storeDomain(domain3, true);
    repo.storeDomain(domain4, true);
    // JNDI
    // $NON-NLS-1$ //$NON-NLS-2$
    System.setProperty("java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory");
    // $NON-NLS-1$ //$NON-NLS-2$
    System.setProperty("org.osjava.sj.root", TestResourceLocation.TEST_RESOURCES + "/solution/system/simple-jndi");
    // $NON-NLS-1$ //$NON-NLS-2$
    System.setProperty("org.osjava.sj.delimiter", "/");
}
Also used : HashMap(java.util.HashMap) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) IMetadataDomainRepository(org.pentaho.metadata.repository.IMetadataDomainRepository) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString) Domain(org.pentaho.metadata.model.Domain) File(java.io.File) BigDecimal(java.math.BigDecimal) FileSystemBackedUnifiedRepository(org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) Before(org.junit.Before)

Aggregations

FileSystemBackedUnifiedRepository (org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository)19 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)12 File (java.io.File)11 Before (org.junit.Before)10 MicroPlatform (org.pentaho.test.platform.engine.core.MicroPlatform)8 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)7 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)5 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)4 RepositoryUtils (org.pentaho.platform.repository2.unified.RepositoryUtils)4 InputStream (java.io.InputStream)3 Test (org.junit.Test)3 IMetadataDomainRepository (org.pentaho.metadata.repository.IMetadataDomainRepository)3 PentahoMetadataDomainRepository (org.pentaho.platform.plugin.services.metadata.PentahoMetadataDomainRepository)3 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 OutputStream (java.io.OutputStream)2 EnumSet (java.util.EnumSet)2 HashMap (java.util.HashMap)2 IAuthorizationPolicy (org.pentaho.platform.api.engine.IAuthorizationPolicy)2 IAclNodeHelper (org.pentaho.platform.api.repository2.unified.IAclNodeHelper)2