use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.
the class JcrAllowableAction method getHierarchy.
@Override
public List<Action> getHierarchy() {
try {
List<Action> list = new ArrayList<>();
Node current = getNode();
while (current.getPrimaryNodeType().isNodeType(NODE_TYPE)) {
list.add(0, JcrUtil.createJcrObject(current, JcrAllowableAction.class));
current = current.getParent();
}
return list;
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Failed to derive the perentage of action node: " + getNode(), e);
}
}
use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.
the class JcrObligation method setMetrics.
public void setMetrics(Set<Metric> metrics) {
try {
NodeIterator nodes = this.node.getNodes(METRICS);
while (nodes.hasNext()) {
Node metricNode = (Node) nodes.next();
metricNode.remove();
}
for (Metric metric : metrics) {
Node metricNode = this.node.addNode(METRICS, METRIC_TYPE);
JcrPropertyUtil.setProperty(metricNode, NAME, metric.getClass().getSimpleName());
JcrPropertyUtil.setProperty(metricNode, DESCRIPTION, metric.getDescription());
JcrUtil.addGenericJson(metricNode, JSON, metric);
}
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Failed to retrieve the metric nodes", e);
}
}
use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.
the class JcrServiceLevelAgreement method getObligationGroups.
/* (non-Javadoc)
* @see com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement#getObligationGroups()
*/
@Override
public List<ObligationGroup> getObligationGroups() {
try {
@SuppressWarnings("unchecked") Iterator<Node> defItr = (Iterator<Node>) this.node.getNodes(DEFAULT_GROUP);
@SuppressWarnings("unchecked") Iterator<Node> grpItr = (Iterator<Node>) this.node.getNodes(GROUPS);
return Lists.newArrayList(Iterators.concat(Iterators.transform(defItr, (groupNode) -> {
return JcrUtil.createJcrObject(groupNode, JcrObligationGroup.class, JcrServiceLevelAgreement.this);
}), Iterators.transform(grpItr, (groupNode) -> {
return JcrUtil.createJcrObject(groupNode, JcrObligationGroup.class, JcrServiceLevelAgreement.this);
})));
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Failed to retrieve the obligation nodes", e);
}
}
use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.
the class JcrServiceLevelAgreementCheck method setActionConfigurations.
public void setActionConfigurations(List<? extends ServiceLevelAgreementActionConfiguration> actionConfigurations) {
try {
NodeIterator nodes = this.node.getNodes(ACTION_CONFIGURATIONS);
while (nodes.hasNext()) {
Node metricNode = (Node) nodes.next();
metricNode.remove();
}
for (ServiceLevelAgreementActionConfiguration actionConfiguration : actionConfigurations) {
Node node = this.node.addNode(ACTION_CONFIGURATIONS, ACTION_CONFIGURATION_TYPE);
JcrPropertyUtil.setProperty(node, JcrPropertyConstants.TITLE, actionConfiguration.getClass().getSimpleName());
ServiceLevelAgreementActionConfig annotation = actionConfiguration.getClass().getAnnotation(ServiceLevelAgreementActionConfig.class);
String desc = actionConfiguration.getClass().getSimpleName();
if (annotation != null) {
desc = annotation.description();
}
JcrPropertyUtil.setProperty(node, DESCRIPTION, desc);
JcrUtil.addGenericJson(node, JcrPropertyConstants.JSON, actionConfiguration);
}
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Failed to retrieve the metric nodes", e);
}
}
use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.
the class JcrServiceLevelAgreementProvider method builder.
public ServiceLevelAgreementBuilder builder(ServiceLevelAgreement.ID id) {
try {
Session session = getSession();
Node slaNode = session.getNodeByIdentifier(id.toString());
if (slaNode == null || !slaNode.isNodeType("tba:sla")) {
throw new MetadataRepositoryException("Failed to get sla node for " + id);
}
// clear out any obligations/metrics associated to this node as the builder will bring in new ones
JcrServiceLevelAgreement sla = new JcrServiceLevelAgreement(slaNode);
sla.clear();
return builder(slaNode);
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Failed to create an sla node", e);
}
}
Aggregations