}
private CompleteProduct toCompleteProduct(Document doc, boolean getRefs,
boolean getMetadata) {
Product product = new Product();
Metadata metadata = new Metadata();
CompleteProduct completeProduct = new CompleteProduct();
product.setProductId(doc.get("product_id"));
product.setProductName(doc.get("product_name"));
product.setProductStructure(doc.get("product_structure"));
product.setTransferStatus(doc.get("product_transfer_status"));
ProductType type = new ProductType();
type.setDescription(doc.get("product_type_desc"));
type.setProductTypeId(doc.get("product_type_id"));
type.setName(doc.get("product_type_name"));
type.setProductRepositoryPath(doc.get("product_type_repoPath"));
type.setVersioner(doc.get("product_type_versioner"));
product.setProductType(type);
if (getMetadata) {
List<Element> elements = null;
try {
elements = valLayer.getElements(type);
} catch (ValidationLayerException e) {
LOG.log(Level.WARNING,
"Unable to obtain metadata for product: ["
+ product.getProductName() + "]: Message: "
+ e.getMessage());
}
if (elements != null) {
for (Iterator<Element> i = elements.iterator(); i.hasNext();) {
Element element = (Element) i.next();
String[] elemValues = doc.getValues(element
.getElementName());
if (elemValues != null && elemValues.length > 0) {
for (int j = 0; j < elemValues.length; j++) {
metadata.addMetadata(element.getElementName(),
elemValues[j]);
}
}
}
}