Add collaboration feature
[sdc.git] / openecomp-be / lib / openecomp-sdc-vendor-software-product-lib / openecomp-sdc-vendor-software-product-core / src / main / java / org / openecomp / sdc / vendorsoftwareproduct / dao / impl / zusammen / convertor / ElementToNicConvertor.java
1 package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
2
3 import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
4 import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
5 import com.amdocs.zusammen.datatypes.item.Info;
6 import org.openecomp.convertor.ElementConvertor;
7 import org.openecomp.core.utilities.file.FileUtils;
8 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
9 import org.openecomp.types.ElementPropertyName;
10
11 public class ElementToNicConvertor extends ElementConvertor <NicEntity>{
12
13   @Override
14   public NicEntity convert( Element element) {
15     NicEntity nicEntity = new NicEntity();
16
17     nicEntity.setId(element.getElementId().getValue());
18     nicEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData())));
19     mapInfoToNicEntity(nicEntity,element.getInfo());
20     return nicEntity;
21   }
22
23   @Override
24   public NicEntity convert( ElementInfo elementInfo) {
25     NicEntity nicEntity = new NicEntity();
26
27     nicEntity.setId(elementInfo.getId().getValue());
28     mapInfoToNicEntity(nicEntity,elementInfo.getInfo());
29     return nicEntity;
30   }
31
32
33   public void mapInfoToNicEntity(NicEntity nicEntity,Info info){
34
35       nicEntity.setCompositionData(
36           info.getProperty(ElementPropertyName.compositionData.name()));
37   }
38
39 }