use of com.thinkbiganalytics.policy.PolicyTransformException in project kylo by Teradata.
the class SchemaDiscoveryRestController method uploadFile.
@POST
@Path("/hive/sample-file")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Determines the schema of the provided file.")
@ApiResponses({ @ApiResponse(code = 200, message = "Returns the schema.", response = Schema.class), @ApiResponse(code = 500, message = "The schema could not be determined.", response = RestResponseStatus.class) })
public Response uploadFile(@FormDataParam("parser") String parserDescriptor, @FormDataParam("file") InputStream fileInputStream, @FormDataParam("file") FormDataContentDisposition fileMetaData) throws Exception {
Schema schema;
SchemaParserAnnotationTransformer transformer = new SchemaParserAnnotationTransformer();
try {
SchemaParserDescriptor descriptor = ObjectMapperSerializer.deserialize(parserDescriptor, SchemaParserDescriptor.class);
FileSchemaParser p = transformer.fromUiModel(descriptor);
// TODO: Detect charset
schema = p.parse(fileInputStream, Charset.defaultCharset(), TableSchemaType.HIVE);
} catch (IOException e) {
throw new WebApplicationException(e.getMessage());
} catch (PolicyTransformException e) {
log.warn("Failed to convert parser", e);
throw new InternalServerErrorException(STRINGS.getString("discovery.transformError"), e);
}
return Response.ok(schema).build();
}
use of com.thinkbiganalytics.policy.PolicyTransformException in project kylo by Teradata.
the class PreconditionPolicyTransformer method getPreconditionObligationGroups.
public List<ObligationGroup> getPreconditionObligationGroups() {
List<ObligationGroup> policies = new ArrayList<>();
if (preconditionRules != null) {
for (PreconditionRule rule : preconditionRules) {
try {
Precondition policy = PreconditionAnnotationTransformer.instance().fromUiModel(rule);
policies.addAll(Lists.newArrayList(policy.buildPreconditionObligations()));
} catch (PolicyTransformException e) {
throw new RuntimeException(e);
}
}
}
return policies;
}
use of com.thinkbiganalytics.policy.PolicyTransformException in project kylo by Teradata.
the class PreconditionPolicyTransformer method getPreconditionPolicies.
public List<Precondition> getPreconditionPolicies() {
List<Precondition> policies = new ArrayList<>();
if (preconditionRules != null) {
for (PreconditionRule rule : preconditionRules) {
try {
Precondition policy = PreconditionAnnotationTransformer.instance().fromUiModel(rule);
policies.add(policy);
} catch (PolicyTransformException e) {
throw new RuntimeException(e);
}
}
}
return policies;
}
use of com.thinkbiganalytics.policy.PolicyTransformException in project kylo by Teradata.
the class ServiceLevelAgreementMetricTransformerHelper method getServiceLevelAgreement.
public ServiceLevelAgreement getServiceLevelAgreement(ServiceLevelAgreementGroup serviceLevelAgreement) {
ServiceLevelAgreement transformedSla = new ServiceLevelAgreement();
transformedSla.setId(serviceLevelAgreement.getId());
transformedSla.setName(serviceLevelAgreement.getName());
transformedSla.setDescription(serviceLevelAgreement.getDescription());
for (ServiceLevelAgreementRule rule : serviceLevelAgreement.getRules()) {
try {
ObligationGroup group = new ObligationGroup();
Metric policy = ServiceLevelAgreementMetricTransformer.instance().fromUiModel(rule);
Obligation obligation = new Obligation(policy.getDescription());
obligation.setMetrics(Lists.newArrayList(policy));
group.addObligation(obligation);
group.setCondition(rule.getCondition().name());
transformedSla.addGroup(group);
} catch (PolicyTransformException e) {
throw new RuntimeException(e);
}
}
return transformedSla;
}
use of com.thinkbiganalytics.policy.PolicyTransformException in project kylo by Teradata.
the class ServiceLevelAgreementMetricTransformerHelper method getActionConfigurations.
public List<ServiceLevelAgreementActionConfiguration> getActionConfigurations(ServiceLevelAgreementGroup serviceLevelAgreement) {
List<ServiceLevelAgreementActionConfiguration> actionConfigurations = new ArrayList<>();
if (serviceLevelAgreement.getActionConfigurations() != null) {
for (ServiceLevelAgreementActionUiConfigurationItem agreementActionUiConfigurationItem : serviceLevelAgreement.getActionConfigurations()) {
try {
ServiceLevelAgreementActionConfiguration actionConfiguration = ServiceLevelAgreementActionConfigTransformer.instance().fromUiModel(agreementActionUiConfigurationItem);
actionConfigurations.add(actionConfiguration);
} catch (PolicyTransformException e) {
throw new RuntimeException(e);
}
}
}
return actionConfigurations;
}
Aggregations