Search in sources :

Example 1 with IContentInfo

use of org.pentaho.platform.api.engine.IContentInfo in project pentaho-platform by pentaho.

the class PentahoSystemPluginManager method getContentTypes.

@Override
public Set<String> getContentTypes() {
    final HashSet<String> types = new HashSet<String>();
    final List<IContentInfo> contentInfos = PentahoSystem.getAll(IContentInfo.class, null);
    for (IContentInfo contentInfo : contentInfos) {
        types.add(contentInfo.getExtension());
    }
    return types;
}
Also used : IContentInfo(org.pentaho.platform.api.engine.IContentInfo) HashSet(java.util.HashSet)

Example 2 with IContentInfo

use of org.pentaho.platform.api.engine.IContentInfo in project pentaho-platform by pentaho.

the class SystemResource method getExecutableTypes.

/**
 * Retrieves the list of supported content type in the platform
 *
 * @return list of <code> ExecutableFileTypeDto </code>
 */
@Path("/executableTypes")
@GET
@Produces({ APPLICATION_XML, APPLICATION_JSON })
@Facet(name = "Unsupported")
public Response getExecutableTypes() {
    ArrayList<ExecutableFileTypeDto> executableTypes = new ArrayList<ExecutableFileTypeDto>();
    for (String contentType : pluginManager.getContentTypes()) {
        IContentInfo contentInfo = pluginManager.getContentTypeInfo(contentType);
        ExecutableFileTypeDto executableFileType = new ExecutableFileTypeDto();
        executableFileType.setDescription(contentInfo.getDescription());
        executableFileType.setExtension(contentInfo.getExtension());
        executableFileType.setTitle(contentInfo.getTitle());
        executableFileType.setCanSchedule(hasOperationId(contentInfo.getOperations(), "SCHEDULE_NEW"));
        executableFileType.setCanEdit(hasOperationId(contentInfo.getOperations(), "EDIT"));
        executableTypes.add(executableFileType);
    }
    final GenericEntity<List<ExecutableFileTypeDto>> entity = new GenericEntity<List<ExecutableFileTypeDto>>(executableTypes) {
    };
    return Response.ok(entity).build();
}
Also used : IContentInfo(org.pentaho.platform.api.engine.IContentInfo) GenericEntity(javax.ws.rs.core.GenericEntity) ExecutableFileTypeDto(org.pentaho.platform.repository2.unified.webservices.ExecutableFileTypeDto) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Facet(org.codehaus.enunciate.Facet)

Example 3 with IContentInfo

use of org.pentaho.platform.api.engine.IContentInfo in project pentaho-platform by pentaho.

the class PentahoSystemPluginManager method registerContentTypes.

protected void registerContentTypes(IPlatformPlugin plugin, ClassLoader loader, GenericApplicationContext beanFactory) throws PlatformPluginRegistrationException {
    // index content types and define any file meta providersIContentGeneratorInfo
    for (IContentInfo info : plugin.getContentInfos()) {
        final HashMap<String, Object> attributes = new HashMap<String, Object>();
        attributes.put(PLUGIN_ID, plugin.getId());
        attributes.put("extension", info.getExtension());
        IPentahoObjectRegistration handle = PentahoSystem.registerReference(new SingletonPentahoObjectReference.Builder<IContentInfo>(IContentInfo.class).object(info).attributes(attributes).build(), IContentInfo.class);
        registerReference(plugin.getId(), handle);
    }
}
Also used : IContentInfo(org.pentaho.platform.api.engine.IContentInfo) HashMap(java.util.HashMap) BeanDefinitionBuilder(org.springframework.beans.factory.support.BeanDefinitionBuilder) IPentahoObjectRegistration(org.pentaho.platform.api.engine.IPentahoObjectRegistration)

Example 4 with IContentInfo

use of org.pentaho.platform.api.engine.IContentInfo in project pentaho-platform by pentaho.

the class StandaloneSpringPentahoObjectFactoryTest method testSessionProperties.

public void testSessionProperties() throws Exception {
    StandaloneSession session = new StandaloneSession();
    PentahoSessionHolder.setSession(session);
    StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory();
    factory.init("src/test/resources/solution/system/pentahoObjects.spring.xml", null);
    PentahoSystem.registerObjectFactory(factory);
    IContentInfo obj = PentahoSystem.get(IContentInfo.class, session);
    assertEquals("Test Session", obj.getTitle());
    IContentInfo obj_again = PentahoSystem.get(IContentInfo.class, session);
    assertSame(obj_again, obj);
    session = new StandaloneSession();
    PentahoSessionHolder.setSession(session);
    IContentInfo obj_newer = PentahoSystem.get(IContentInfo.class, session);
    assertNotSame(obj, obj_newer);
}
Also used : IContentInfo(org.pentaho.platform.api.engine.IContentInfo) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) StandaloneSpringPentahoObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)

Example 5 with IContentInfo

use of org.pentaho.platform.api.engine.IContentInfo in project pentaho-platform by pentaho.

the class SystemPathPluginProviderIT method testLoadContentGenerators.

@SuppressWarnings("deprecation")
@Test
public void testLoadContentGenerators() throws PlatformPluginRegistrationException {
    microPlatform.init();
    List<IPlatformPlugin> plugins = provider.getPlugins(new StandaloneSession());
    IPlatformPlugin plugin = (IPlatformPlugin) CollectionUtils.find(plugins, new PluginNameMatcherPredicate("content-generator-plugin"));
    assertNotNull("content-generator-plugin should have been found", plugin);
    List<IContentInfo> contentTypes = plugin.getContentInfos();
    Object contentType = CollectionUtils.find(contentTypes, new Predicate() {

        public boolean evaluate(Object object) {
            IContentInfo type = (IContentInfo) object;
            return type.getTitle().equals("Good Test Type");
        }
    });
    assertNotNull("\"Good Test Type\" should have been loaded", contentType);
    assertNotNull("\"Good Test Type\" extension definition is incorrect", ((IContentInfo) contentType).getExtension().equals("good-content-type"));
    IContentInfo contentInfo = (IContentInfo) contentType;
    IPluginOperation operation = contentInfo.getOperations().listIterator().next();
    assertEquals("Missing perspective", "custom-perspective", operation.getPerspective());
    assertEquals("\"Test Type Missing type\" should not have been loaded", 0, CollectionUtils.countMatches(contentTypes, new Predicate() {

        public boolean evaluate(Object object) {
            IContentInfo type = (IContentInfo) object;
            return type.getTitle().equals("Test Type Missing type");
        }
    }));
    assertEquals("\"test-type-missing-title\" should not have been loaded", 0, CollectionUtils.countMatches(contentTypes, new Predicate() {

        public boolean evaluate(Object object) {
            IContentInfo type = (IContentInfo) object;
            return type.getExtension().equals("test-type-missing-title");
        }
    }));
}
Also used : IContentInfo(org.pentaho.platform.api.engine.IContentInfo) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) IPluginOperation(org.pentaho.platform.api.engine.IPluginOperation) IPlatformPlugin(org.pentaho.platform.api.engine.IPlatformPlugin) Predicate(org.apache.commons.collections.Predicate) Test(org.junit.Test)

Aggregations

IContentInfo (org.pentaho.platform.api.engine.IContentInfo)9 GET (javax.ws.rs.GET)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 IPluginOperation (org.pentaho.platform.api.engine.IPluginOperation)4 ArrayList (java.util.ArrayList)3 Facet (org.codehaus.enunciate.Facet)3 List (java.util.List)2 GenericEntity (javax.ws.rs.core.GenericEntity)2 Test (org.junit.Test)2 IPluginManager (org.pentaho.platform.api.engine.IPluginManager)2 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)2 ExecutableFileTypeDto (org.pentaho.platform.repository2.unified.webservices.ExecutableFileTypeDto)2 URL (java.net.URL)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Predicate (org.apache.commons.collections.Predicate)1 StatusCodes (org.codehaus.enunciate.jaxrs.StatusCodes)1 IPentahoObjectRegistration (org.pentaho.platform.api.engine.IPentahoObjectRegistration)1 IPlatformPlugin (org.pentaho.platform.api.engine.IPlatformPlugin)1