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;
}
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();
}
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);
}
}
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);
}
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");
}
}));
}
Aggregations