2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
23 import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
24 import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
25 import com.amdocs.zusammen.datatypes.item.Info;
26 import org.openecomp.convertor.ElementConvertor;
27 import org.openecomp.core.utilities.file.FileUtils;
28 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
29 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessType;
31 import java.nio.ByteBuffer;
33 public class ElementToProcessConvertor extends ElementConvertor<ProcessEntity> {
35 public static final String NAME = "name";
36 public static final String ARTIFACT_NAME = "artifactName";
37 public static final String DESCRIPTION = "description";
38 public static final String PROCESS_TYPE = "processType";
41 public ProcessEntity convert(Element element) {
42 if (element == null) {
45 ProcessEntity processEntity = new ProcessEntity();
46 processEntity.setId(element.getElementId().getValue());
47 processEntity.setArtifact(ByteBuffer.wrap(FileUtils.toByteArray(element.getData())));
48 mapInfoToProcessEntity(processEntity, element.getInfo());
53 public ProcessEntity convert(ElementInfo elementInfo) {
54 if (elementInfo == null) {
57 ProcessEntity processEntity = new ProcessEntity();
58 processEntity.setId(elementInfo.getId().getValue());
59 mapInfoToProcessEntity(processEntity, elementInfo.getInfo());
63 public void mapInfoToProcessEntity(ProcessEntity processEntity, Info info) {
64 processEntity.setName(info.getProperty(NAME));
65 processEntity.setArtifactName(info.getProperty(ARTIFACT_NAME));
66 processEntity.setDescription(info.getProperty(DESCRIPTION));
67 processEntity.setType(info.getProperty
68 (PROCESS_TYPE) != null ? ProcessType.valueOf(info.getProperty
69 (PROCESS_TYPE)) : null);