use of com.synopsys.integration.detectable.detectables.bazel.pipeline.step.model.AttributeItem in project synopsys-detect by blackducksoftware.
the class HaskellCabalLibraryJsonProtoParser method extractDependency.
private NameVersion extractDependency(List<AttributeItem> attributes) throws DetectableException {
String dependencyName = null;
String dependencyVersion = null;
for (AttributeItem attributeItem : attributes) {
if ("name".equals(attributeItem.getName())) {
dependencyName = attributeItem.getStringValue();
} else if ("version".equals(attributeItem.getName())) {
dependencyVersion = attributeItem.getStringValue();
}
if (dependencyName != null && dependencyVersion != null) {
return new NameVersion(dependencyName, dependencyVersion);
}
}
throw new DetectableException(String.format("Dependency name/version not found in attribute list: %s", attributes));
}
use of com.synopsys.integration.detectable.detectables.bazel.pipeline.step.model.AttributeItem in project synopsys-detect by blackducksoftware.
the class HaskellCabalLibraryJsonProtoParser method extractAddDependencies.
private void extractAddDependencies(String jsonProtoString, List<NameVersion> dependencies, ResultItem result) throws DetectableException {
if (result == null || result.getTarget() == null) {
throw new DetectableException(String.format("Unable to parse target from result inJSON proto string: %s", jsonProtoString));
}
Target target = result.getTarget();
if ("RULE".equals(target.getType())) {
if (target.getRule() == null || target.getRule().getAttribute() == null) {
throw new DetectableException(String.format("Unable to parse attributes from rule inJSON proto string: %s", jsonProtoString));
}
List<AttributeItem> attributes = target.getRule().getAttribute();
NameVersion dependency = extractDependency(attributes);
logger.debug("Adding dependency {}/{}}", dependency.getName(), dependency.getVersion());
dependencies.add(dependency);
}
}
Aggregations