use of com.thinkbiganalytics.metadata.api.extension.ExtensibleType in project kylo by Teradata.
the class ExtensionsController method updateType.
/**
* an endpoint to allow updating of an extensible type
*
* @param id the id of the extensible type
* @param descr a descriptor with the type info
* @return the extensible type as persisted to the metadata store
*/
@Path("type/{id}")
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public ExtensibleTypeDescriptor updateType(@PathParam("id") String id, ExtensibleTypeDescriptor descr) {
return metadata.read(() -> {
this.accessController.checkPermission(AccessController.SERVICES, MetadataAccessControl.ADMIN_METADATA);
ExtensibleType.ID domainId = this.typeProvider.resolve(id);
ExtensibleType type = ExtensiblesModel.updateType(descr, domainId, this.typeProvider);
return ExtensiblesModel.DOMAIN_TO_TYPE.apply(type);
});
}
use of com.thinkbiganalytics.metadata.api.extension.ExtensibleType in project kylo by Teradata.
the class ExtensionsController method getType.
/**
* gets an extensible type descriptor by its' name or ID
*
* @param id the name or id of the desired extensible type descriptor
* @return the extensible type descriptor
*/
@Path("type/{nameOrId}")
@GET
@Produces(MediaType.APPLICATION_JSON)
public ExtensibleTypeDescriptor getType(@PathParam("nameOrId") String id) {
return metadata.read(() -> {
this.accessController.checkPermission(AccessController.SERVICES, MetadataAccessControl.ACCESS_METADATA);
ExtensibleType.ID domainId = null;
String name = null;
ExtensibleType type = null;
try {
domainId = this.typeProvider.resolve(id);
} catch (IllegalArgumentException e) {
name = id;
}
if (domainId != null) {
type = this.typeProvider.getType(domainId);
} else {
type = this.typeProvider.getType(name);
}
if (type != null) {
return ExtensiblesModel.DOMAIN_TO_TYPE.apply(type);
} else {
throw new WebApplicationException("No type with the given ID exists: " + id, Response.SC_NOT_FOUND);
}
});
}
use of com.thinkbiganalytics.metadata.api.extension.ExtensibleType in project kylo by Teradata.
the class JcrExtensibleTypeProvider method getTypesList.
private List<ExtensibleType> getTypesList(final String typeName) {
final Session session = getSession();
try {
final List<ExtensibleType> list = new ArrayList<>();
final NodeTypeManager typeMgr = session.getWorkspace().getNodeTypeManager();
final NodeTypeIterator typeItr = typeMgr.getPrimaryNodeTypes();
final NodeType extensibleType = typeMgr.getNodeType(typeName);
while (typeItr.hasNext()) {
final NodeType nodeType = (NodeType) typeItr.next();
if (nodeType.isNodeType(extensibleType.getName()) && !nodeType.equals(extensibleType)) {
String nodeTypePath = ExtensionsConstants.TYPES + "/" + nodeType.getName();
if (session.getRootNode().hasNode(nodeTypePath)) {
final Node typeNode = session.getRootNode().getNode(nodeTypePath);
list.add(new JcrExtensibleType(typeNode, nodeType));
}
}
}
return list;
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Failed to lookup all extensible types", e);
}
}
use of com.thinkbiganalytics.metadata.api.extension.ExtensibleType in project kylo by Teradata.
the class JcrPropertyTest method testGetPropertyTypes.
@Test
public void testGetPropertyTypes() throws RepositoryException {
Map<String, FieldDescriptor.Type> propertyTypeMap = metadata.commit(() -> {
provider.ensureTypeDescriptors();
ExtensibleType feedType = provider.getType("tba:feed");
Set<FieldDescriptor> fields = feedType.getFieldDescriptors();
Map<String, FieldDescriptor.Type> map = new HashMap<>();
for (FieldDescriptor field : fields) {
map.put(field.getName(), field.getType());
}
return map;
}, MetadataAccess.SERVICE);
log.info("Property Types {} ", propertyTypeMap);
}
use of com.thinkbiganalytics.metadata.api.extension.ExtensibleType in project kylo by Teradata.
the class JcrExtensibleProvidersTest method testGetPersonType.
@Test(dependsOnMethods = "testCreatePersonType")
public void testGetPersonType() {
final ExtensibleType.ID id = metadata.commit(() -> {
ExtensibleType type = typeProvider.getType("Person");
return type.getId();
}, MetadataAccess.SERVICE);
assertThat(id).isNotNull();
Map<String, FieldDescriptor.Type> fields = metadata.commit(() -> {
ExtensibleType type = typeProvider.getType("Person");
Map<String, FieldDescriptor.Type> map = new HashMap<>();
for (FieldDescriptor descr : type.getFieldDescriptors()) {
map.put(descr.getName(), descr.getType());
}
return map;
}, MetadataAccess.SERVICE);
assertThat(fields).isNotNull();
assertThat(fields).containsEntry("name", FieldDescriptor.Type.STRING);
assertThat(fields).containsEntry("description", FieldDescriptor.Type.STRING);
assertThat(fields).containsEntry("age", FieldDescriptor.Type.LONG);
}
Aggregations