1 package org.openecomp.sdc.model.impl.zusammen;
3 import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
4 import com.amdocs.zusammen.datatypes.SessionContext;
5 import com.amdocs.zusammen.datatypes.item.Action;
6 import com.amdocs.zusammen.datatypes.item.ElementContext;
7 import org.openecomp.core.model.dao.EnrichedServiceModelDao;
8 import org.openecomp.core.model.types.ServiceArtifact;
9 import org.openecomp.core.model.types.ServiceElement;
10 import org.openecomp.core.utilities.file.FileUtils;
11 import org.openecomp.core.zusammen.api.ZusammenAdaptor;
12 import org.openecomp.core.zusammen.api.ZusammenUtil;
13 import org.openecomp.sdc.datatypes.model.ElementType;
14 import org.openecomp.sdc.logging.api.Logger;
15 import org.openecomp.sdc.logging.api.LoggerFactory;
16 import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
18 import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
20 public class EnrichedServiceModelDaoZusammenImpl extends ServiceModelDaoZusammenImpl implements
21 EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> {
23 private static final Logger logger =
24 LoggerFactory.getLogger(EnrichedServiceModelDaoZusammenImpl.class);
26 public EnrichedServiceModelDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
27 super(zusammenAdaptor);
28 this.elementType = ElementType.EnrichedServiceModel;
32 public void storeExternalArtifact(ServiceArtifact serviceArtifact) {
33 ZusammenElement artifact = buildArtifactElement(serviceArtifact.getName(),
34 FileUtils.toByteArray(serviceArtifact.getContent()), Action.CREATE);
36 ZusammenElement artifacts = buildStructuralElement(ElementType.Artifacts, Action.IGNORE);
37 artifacts.addSubElement(artifact);
39 ZusammenElement enrichedServiceModel = buildStructuralElement(elementType, Action.IGNORE);
40 enrichedServiceModel.addSubElement(artifacts);
42 ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE);
43 vspModel.addSubElement(enrichedServiceModel);
45 SessionContext context = ZusammenUtil.createSessionContext();
46 ElementContext elementContext =
47 new ElementContext(serviceArtifact.getVspId(), serviceArtifact.getVersion().getId());
49 .saveElement(context, elementContext, vspModel, "add service external artifact.");
52 "Finished adding artifact to enriched service model for VendorSoftwareProduct id -> {}",
53 elementContext.getItemId().getValue());