diff options
author | Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> | 2021-02-03 13:56:31 +0100 |
---|---|---|
committer | Dan Timoney <dtimoney@att.com> | 2021-02-05 16:52:27 -0500 |
commit | 80ebbf5b525b1a251f8e0eebd4a841d85716cf65 (patch) | |
tree | d68f747f92dc0c5e6a938474e252e26db63138e7 /sdnr/wt/data-provider/model | |
parent | 4e69f3358d31173a222b275e2a82da692846aa1a (diff) |
Update common and data-provider
common and data-provider migrated to Aluminium
Issue-ID: CCSDK-3111
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Change-Id: Ifb4ddb60f84ca7585137e04bc94d44885fe1f5f4
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/data-provider/model')
5 files changed, 106 insertions, 56 deletions
diff --git a/sdnr/wt/data-provider/model/pom.xml b/sdnr/wt/data-provider/model/pom.xml index 0f8ce415a..b3f39d955 100644 --- a/sdnr/wt/data-provider/model/pom.xml +++ b/sdnr/wt/data-provider/model/pom.xml @@ -29,11 +29,11 @@ <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.1.0</version> + <version>2.1.1-SNAPSHOT</version> <relativePath/> </parent> - <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> + <groupId>org.onap.ccsdk.features.sdnr.wt.aluminium.sr1</groupId> <artifactId>sdnr-wt-data-provider-model</artifactId> <version>1.1.1-SNAPSHOT</version> <packaging>bundle</packaging> @@ -61,6 +61,10 @@ <artifactId>sdnr-wt-common</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + </dependency> </dependencies> <build> diff --git a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/NetconfTimeStampImpl.java b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/NetconfTimeStampImpl.java index c7f921708..bd71d5ba1 100644 --- a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/NetconfTimeStampImpl.java +++ b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/NetconfTimeStampImpl.java @@ -24,6 +24,7 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.util.Date; +import org.eclipse.jdt.annotation.Nullable; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; import org.slf4j.Logger; @@ -66,6 +67,10 @@ public class NetconfTimeStampImpl implements NetconfTimeStamp { private static final Logger LOG = LoggerFactory.getLogger(NetconfTimeStamp.class); private static final NetconfTimeStamp CONVERTER = new NetconfTimeStampImpl(); + private static final String TESTPATTERNSTRING = "2017-01-01T00:00:00.0Z"; + //private static final String INITIALPATTERN = "0000-00-00T00:00:00.0Z"; + + private static final DateAndTime TESTPATTERN = new DateAndTime(TESTPATTERNSTRING); /** * Specify the input format expected from netconf, and from specific devices. @@ -91,7 +96,7 @@ public class NetconfTimeStampImpl implements NetconfTimeStamp { /** * Use this function to get the converter - * + * * @return global converter */ public static NetconfTimeStamp getConverter() { @@ -110,7 +115,7 @@ public class NetconfTimeStampImpl implements NetconfTimeStamp { /** * Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format - * + * * @return String with Date in NETCONF/YANG Format Version 1.0. */ @Override @@ -132,7 +137,7 @@ public class NetconfTimeStampImpl implements NetconfTimeStamp { /** * Get time from date as NETCONF specific type NETCONF/YANG 1.0 Format in GMT - * + * * @param date specifying the date and time * @return DateAndTime Type 1.0. Date in NETCONF/YANG Format Version 1.0. */ @@ -143,7 +148,7 @@ public class NetconfTimeStampImpl implements NetconfTimeStamp { /** * Get time from date as NETCONF specific type NETCONF/YANG 1.0 Format in GMT - * + * * @param date specifying the date and time * @return DateAndTime Type 1.0. Date in NETCONF/YANG Format Version 1.0. */ @@ -189,6 +194,14 @@ public class NetconfTimeStampImpl implements NetconfTimeStamp { return "Malformed date: " + netconfTime; // Error handling } + /** + * Return testpattern + * @return + */ + public static @Nullable DateAndTime getTestpatternDateAndTime() { + return TESTPATTERN; + } + /*---------------------------------------------------- * Private functions */ diff --git a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/ScalarTypeObject.java b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/ScalarTypeObject.java new file mode 100644 index 000000000..da52f3125 --- /dev/null +++ b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/ScalarTypeObject.java @@ -0,0 +1,49 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types; + +public class ScalarTypeObject { + + // constants + // end of constants + + // variables + // end of variables + + // constructors + // end of constructors + + // getters and setters + // end of getters and setters + + // private methods + // end of private methods + + // public methods + // end of public methods + + // static methods + // end of static methods + + // private classes + // end of private classes +} diff --git a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/YangHelper2.java b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/YangHelper2.java index 339bf7c6e..dd90d29c8 100644 --- a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/YangHelper2.java +++ b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/YangHelper2.java @@ -69,10 +69,18 @@ public class YangHelper2 { public static @NonNull Integer getInteger(@Nullable Uint16 val) { return val.intValue(); } + + public static @NonNull Long getInteger(@Nullable Long val) { + return val; + } + + public static @NonNull Long getInteger(@Nullable Uint32 val) { + return val.longValue(); + } /** * Aluminium version */ - public static <K extends Identifier<T>,T extends Identifiable<K>> Map<K, T> getListOrMapALUMINIUM(Class<K> clazz, List<T> list) { + public static <K extends Identifier<T>,T extends Identifiable<K>> Map<K, T> getListOrMap(Class<K> clazz, List<T> list) { Map<K,T> map = new HashMap<>(); for(T listelement:list) { Constructor<K> constructor; @@ -86,17 +94,20 @@ public class YangHelper2 { } return map; } - public static <K extends Identifier<T>,T extends Identifiable<K>> Map<K, T> getListOrMapALUMINIUM(Class<K> clazz, T listElement) { - return getListOrMapALUMINIUM(clazz, Arrays.asList(listElement) ); + public static <K extends Identifier<T>,T extends Identifiable<K>> Map<K, T> getListOrMap(Class<K> clazz, T listElement) { + return getListOrMap(clazz, Arrays.asList(listElement) ); } - /** - * Sodium version - */ - public static <K extends Identifier<T>,T extends Identifiable<K>> List<T> getListOrMap(Class<K> clazz, List<T> list) { - return list; + public static Uint32 getLongOrUint32(long longVal) { + return Uint32.valueOf(longVal); + } + public static Uint32 getLongOrUint32(Long longVal) { + return Uint32.valueOf(longVal); + } + public static Uint64 getBigIntegerOrUint64(BigInteger value) { + return Uint64.valueOf(value); } - public static <K extends Identifier<T>,T extends Identifiable<K>> List<T> getListOrMap(Class<K> clazz, T listElement) { - return Arrays.asList(listElement); + public static Class<?> getScalarTypeObjectClass() { + return org.opendaylight.yangtools.yang.binding.ScalarTypeObject.class; } } diff --git a/sdnr/wt/data-provider/model/src/main/java/org/opendaylight/yang/gen/v1/http/org/openroadm/pm/types/rev191129/PmDataTypeBuilder.java b/sdnr/wt/data-provider/model/src/main/java/org/opendaylight/yang/gen/v1/http/org/openroadm/pm/types/rev191129/PmDataTypeBuilder.java index b660787c6..f89197b82 100644 --- a/sdnr/wt/data-provider/model/src/main/java/org/opendaylight/yang/gen/v1/http/org/openroadm/pm/types/rev191129/PmDataTypeBuilder.java +++ b/sdnr/wt/data-provider/model/src/main/java/org/opendaylight/yang/gen/v1/http/org/openroadm/pm/types/rev191129/PmDataTypeBuilder.java @@ -1,11 +1,7 @@ package org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129; import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.Optional; import org.opendaylight.yangtools.yang.common.Uint64; /** @@ -17,20 +13,17 @@ import org.opendaylight.yangtools.yang.common.Uint64; * finished by the user. This class is generated only once to prevent loss of user code. * */ -@JsonPOJOBuilder(buildMethodName = "build", withPrefix = "with") +@JsonPOJOBuilder(buildMethodName = "build", withPrefix = "set") public class PmDataTypeBuilder { private Uint64 _uint64; - private BigInteger _unint64; private Long _int64; private BigDecimal _decimal64; - public PmDataTypeBuilder() { - System.out.println("-- Builder"); - } + public PmDataTypeBuilder() {} - public PmDataTypeBuilder setUnint64(String v) { - _unint64 = new BigInteger(v); - return this; + //Aluminium uses constructor + public PmDataTypeBuilder(String v) { + this.setUint64(v); } public PmDataTypeBuilder setUint64(String v) { @@ -39,7 +32,7 @@ public class PmDataTypeBuilder { } public PmDataTypeBuilder setInt64(String v) { - _int64 = new Long(v); + _int64 = Long.valueOf(v); return this; } @@ -49,37 +42,17 @@ public class PmDataTypeBuilder { } public PmDataType build() { - Optional<Constructor<PmDataType>> cons1; - try { - cons1 = Optional.of(PmDataType.class.getConstructor(BigInteger.class)); - } catch (NoSuchMethodException | SecurityException e) { - cons1 = Optional.empty(); - } - Optional<Constructor<PmDataType>> cons2; - try { - cons2 = Optional.of(PmDataType.class.getConstructor(Uint64.class)); - } catch (NoSuchMethodException | SecurityException e) { - cons2 = Optional.empty(); - } - - try { - if (_unint64 != null) { - return cons1.get().newInstance(_unint64); - } else if (_uint64 != null) { - return cons2.get().newInstance(_uint64); - } else if (_int64 != null) { - return new PmDataType(_int64); - } else { - return new PmDataType(_decimal64); - } - } catch (InstantiationException | IllegalAccessException | IllegalArgumentException - | InvocationTargetException e) { - throw new IllegalArgumentException("Wrong stuff"); + if (_uint64 != null) { + return new PmDataType(_uint64); + } else if (_int64 != null) { + return new PmDataType(_int64); + } else { + return new PmDataType(_decimal64); } } public static PmDataType getDefaultInstance(String defaultValue) { - return new PmDataTypeBuilder().setInt64("-1").build(); + return new PmDataTypeBuilder().setUint64(defaultValue).build(); } } |