2 * Copyright © 2016-2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor;
18 import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
19 import org.openecomp.convertor.ElementConvertor;
20 import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity;
21 import org.openecomp.sdc.vendorlicense.dao.types.LimitType;
24 * Created by ayalaben on 9/26/2017
26 public class ElementToLimitConvertor extends ElementConvertor<LimitEntity> {
28 public LimitEntity convert(Element element) {
29 if (element == null) {
32 return mapElementToLimitEntity(element);
35 private LimitEntity mapElementToLimitEntity(Element element) {
36 LimitEntity limit = new LimitEntity();
37 limit.setId(element.getElementId().getValue());
38 limit.setName(element.getInfo().getName());
39 limit.setDescription(element.getInfo().getDescription());
40 limit.setUnit(element.getInfo().getProperty("unit"));
41 limit.setMetric(element.getInfo().getProperty("metric"));
42 limit.setValue(element.getInfo().getProperty("value"));
43 limit.setTime(element.getInfo().getProperty("time"));
44 limit.setAggregationFunction(element.getInfo().getProperty("aggregationFunction"));
45 setLimitType(limit,element.getInfo().getProperty("type"));
50 private void setLimitType(LimitEntity limit, String type) {
51 switch (LimitType.valueOf(type)) {
53 limit.setType(LimitType.ServiceProvider);
56 limit.setType(LimitType.Vendor);