summaryrefslogtreecommitdiffstats
path: root/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
blob: 33788af4e1889e0b51940458991ffe297b5c2d4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;

import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
import com.amdocs.zusammen.datatypes.item.Info;
import org.openecomp.convertor.ElementConvertor;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
import org.openecomp.types.ElementPropertyName;

public class ElementToNicConvertor extends ElementConvertor <NicEntity>{

  @Override
  public NicEntity convert( Element element) {
    NicEntity nicEntity = new NicEntity();

    nicEntity.setId(element.getElementId().getValue());
    nicEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData())));
    mapInfoToNicEntity(nicEntity,element.getInfo());
    return nicEntity;
  }

  @Override
  public NicEntity convert( ElementInfo elementInfo) {
    NicEntity nicEntity = new NicEntity();

    nicEntity.setId(elementInfo.getId().getValue());
    mapInfoToNicEntity(nicEntity,elementInfo.getInfo());
    return nicEntity;
  }


  public void mapInfoToNicEntity(NicEntity nicEntity,Info info){

      nicEntity.setCompositionData(
          info.getProperty(ElementPropertyName.compositionData.name()));
  }

}