diff options
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl')
11 files changed, 960 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceImpl.java new file mode 100644 index 0000000000..2f11b75a98 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceImpl.java @@ -0,0 +1,200 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T 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.openecomp.sdc.vendorlicense.licenseartifacts.impl; + +import org.apache.commons.collections4.MultiValuedMap; +import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; +import org.openecomp.core.utilities.file.FileContentHandler; +import org.openecomp.sdc.vendorlicense.HealingServiceFactory; +import org.openecomp.sdc.vendorlicense.VendorLicenseConstants; +import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; +import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; +import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupModel; +import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; +import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade; +import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory; +import org.openecomp.sdc.vendorlicense.healing.HealingService; +import org.openecomp.sdc.vendorlicense.licenseartifacts.VendorLicenseArtifactsService; +import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.VendorLicenseArtifact; +import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.VnfLicenseArtifact; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.dao.types.VersionableEntity; +import org.openecomp.sdc.versioning.types.VersionInfo; +import org.openecomp.sdc.versioning.types.VersionableEntityAction; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +public class VendorLicenseArtifactsServiceImpl implements VendorLicenseArtifactsService { + + private static final VendorLicenseFacade vendorLicenseFacade = VendorLicenseFacadeFactory + .getInstance().createInterface(); + private static final HealingService healingService = HealingServiceFactory + .getInstance().createInterface(); + + /** + * Create License Artifacts. + * + * @param vspId the vsp id + * @param vlmId the vlm id + * @param vlmVersion the vlm version + * @param featureGroups the feature groups + * @param user the user + * @return FileContentHandler + */ + public FileContentHandler createLicenseArtifacts(String vspId, String vlmId, + Version vlmVersion, + List<String> featureGroups, String user) { + FileContentHandler artifacts = new FileContentHandler(); + String vendorName = getVendorName(vlmId, user); + + artifacts.addFile(VendorLicenseConstants.VNF_ARTIFACT_NAME_WITH_PATH, + createVnfArtifact(vspId, vlmId, vlmVersion, vendorName, featureGroups, user)); + artifacts.addFile(VendorLicenseConstants.VENDOR_LICENSE_MODEL_ARTIFACT_NAME_WITH_PATH, + createVendorLicenseArtifact(vlmId, vendorName, user)); + + return artifacts; + } + + static byte[] createVnfArtifact( + String vspId, String vlmId, Version vlmVersion, + String vendorName, List<String> featureGroups, + String user) { + VnfLicenseArtifact artifact = new VnfLicenseArtifact(); + + artifact.setVspId(vspId); + artifact.setVendorName(vendorName); + for (String featureGroupId : featureGroups) { + FeatureGroupModel featureGroupModel = + vendorLicenseFacade.getFeatureGroupModel(new FeatureGroupEntity( + vlmId, vlmVersion, featureGroupId), user); + Set<EntitlementPoolEntity> entitlementPoolEntities = featureGroupModel.getEntitlementPools(); + Set<LicenseKeyGroupEntity> licenseKeyGroupEntities = featureGroupModel.getLicenseKeyGroups(); + + featureGroupModel.setEntitlementPools( + entitlementPoolEntities.stream() + .map(entitlementPoolEntity -> (EntitlementPoolEntity) healingService + .heal(entitlementPoolEntity, user)) + .collect(Collectors.toSet())); + featureGroupModel.setLicenseKeyGroups( + licenseKeyGroupEntities.stream() + .map(licenseKeyGroupEntity -> (LicenseKeyGroupEntity) healingService + .heal(licenseKeyGroupEntity, user)) + .collect(Collectors.toSet())); + artifact.getFeatureGroups().add(featureGroupModel); + } + + return artifact.toXml().getBytes(); + } + + + static byte[] createVendorLicenseArtifact(String vlmId, String vendorName, String user) { + VendorLicenseArtifact vendorLicenseArtifact = new VendorLicenseArtifact(); + vendorLicenseArtifact.setVendorName(vendorName); + Set<EntitlementPoolEntity> entitlementPoolEntities = new HashSet<>(); + Set<LicenseKeyGroupEntity> licenseKeyGroupEntities = new HashSet<>(); + + List<Version> finalVersions = getFinalVersionsForVlm(vlmId); + for (Version finalVersion : finalVersions) { + entitlementPoolEntities.addAll( + vendorLicenseFacade.listEntitlementPools(vlmId, finalVersion, user)); + licenseKeyGroupEntities.addAll( + vendorLicenseFacade.listLicenseKeyGroups(vlmId, finalVersion, user)); + } + + + entitlementPoolEntities = healEPs(user, filterChangedEntities(entitlementPoolEntities)); + licenseKeyGroupEntities = healLkgs(user, filterChangedEntities(licenseKeyGroupEntities)); + + vendorLicenseArtifact.setEntitlementPoolEntities(entitlementPoolEntities); + vendorLicenseArtifact.setLicenseKeyGroupEntities(licenseKeyGroupEntities); + return vendorLicenseArtifact.toXml().getBytes(); + } + + private static List<VersionableEntity> filterChangedEntities( + Collection<? extends VersionableEntity> versionableEntities) { + MultiValuedMap<String, VersionableEntity> entitiesById = mapById(versionableEntities); + Map<String, VersionableEntity> entitiesByVersionUuId = new HashMap<>(); + List<VersionableEntity> changedOnly = new ArrayList<>(); + + for (String epId : entitiesById.keySet()) { + Collection<VersionableEntity> versionableEntitiesForId = entitiesById.get(epId); + for (VersionableEntity ep : versionableEntitiesForId) { + entitiesByVersionUuId.put(ep.getVersionUuId(), ep); + } + } + + changedOnly.addAll(entitiesByVersionUuId.values()); + + return changedOnly; + } + + private static MultiValuedMap<String, VersionableEntity> mapById( + Collection<? extends VersionableEntity> versionableEntities) { + MultiValuedMap<String, VersionableEntity> mappedById = new ArrayListValuedHashMap<>(); + for (VersionableEntity ve : versionableEntities) { + mappedById.put(ve.getId(), ve); + } + return mappedById; + } + + + private static Set<LicenseKeyGroupEntity> healLkgs( + String user, Collection<? extends VersionableEntity> licenseKeyGroupEntities) { + Set<LicenseKeyGroupEntity> healed = new HashSet<>(); + for (VersionableEntity licenseKeyGroupEntity : licenseKeyGroupEntities) { + healed.add((LicenseKeyGroupEntity) healingService.heal(licenseKeyGroupEntity, user)); + } + + return healed; + } + + private static Set<EntitlementPoolEntity> healEPs( + String user, Collection<? extends VersionableEntity> entitlementPoolEntities) { + Set<EntitlementPoolEntity> healed = new HashSet<>(); + for (VersionableEntity entitlementPoolEntity : entitlementPoolEntities) { + healed.add((EntitlementPoolEntity) healingService.heal(entitlementPoolEntity, user)); + } + + return healed; + } + + private static List<Version> getFinalVersionsForVlm(String vlmId) { + VersionInfo versionInfo = vendorLicenseFacade + .getVersionInfo(vlmId, VersionableEntityAction.Read, ""); + return versionInfo.getFinalVersions(); + + } + + + private static String getVendorName(String vendorLicenseModelId, String user) { + return vendorLicenseFacade + .getVendorLicenseModel(vendorLicenseModelId, null, user) + .getVendorLicenseModel().getVendorName(); + } + +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/FeatureGroupForArtifact.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/FeatureGroupForArtifact.java new file mode 100644 index 0000000000..6dddb9ac69 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/FeatureGroupForArtifact.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T 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.openecomp.sdc.vendorlicense.licenseartifacts.impl.types; + +import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; +import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; + +import java.util.ArrayList; +import java.util.Collection; + +public class FeatureGroupForArtifact { + Collection<EntitlementPoolEntity> entitlementPoolEntities = new ArrayList<>(); + Collection<LicenseKeyGroupEntity> licenseKeyGroupEntities = new ArrayList<>(); + private String name; + private String description; + private String partNumber; + private String id; + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public String getPartNumber() { + return partNumber; + } + + public String getId() { + return id; + } + + public Collection<EntitlementPoolEntity> getEntitlementPoolEntities() { + return entitlementPoolEntities; + } + + public Collection<LicenseKeyGroupEntity> getLicenseKeyGroupEntities() { + return licenseKeyGroupEntities; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/VendorLicenseArtifact.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/VendorLicenseArtifact.java new file mode 100644 index 0000000000..589b7fa668 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/VendorLicenseArtifact.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T 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.openecomp.sdc.vendorlicense.licenseartifacts.impl.types; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; +import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; +import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinEntitlementPoolEntityForVendorLicenseArtifact; +import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinLicenseKeyGroupEntityForVendorLicenseArtifact; + +import java.util.Collection; + +@JacksonXmlRootElement(localName = "vendor-license-model", + namespace = "http://xmlns.openecomp.org/asdc/license-model/1.0") +public class VendorLicenseArtifact extends XmlArtifact { + @JsonProperty(value = "vendor-name") + String vendorName; + + Collection<EntitlementPoolEntity> entitlementPoolEntities; + Collection<LicenseKeyGroupEntity> licenseKeyGroupEntities; + + public String getVendorName() { + return vendorName; + } + + public void setVendorName(String vendorName) { + this.vendorName = vendorName; + } + + @JacksonXmlProperty(isAttribute = false, localName = "entitlement-pool") + @JacksonXmlElementWrapper(localName = "entitlement-pool-list") + public Collection<EntitlementPoolEntity> getEntitlementPoolEntities() { + return entitlementPoolEntities; + } + + public void setEntitlementPoolEntities( + Collection<EntitlementPoolEntity> entitlementPoolEntities) { + this.entitlementPoolEntities = entitlementPoolEntities; + } + + @JacksonXmlProperty(isAttribute = false, localName = "license-key-group") + @JacksonXmlElementWrapper(localName = "license-key-group-list") + public Collection<LicenseKeyGroupEntity> getLicenseKeyGroupEntities() { + return licenseKeyGroupEntities; + } + + public void setLicenseKeyGroupEntities( + Collection<LicenseKeyGroupEntity> licenseKeyGroupEntities) { + this.licenseKeyGroupEntities = licenseKeyGroupEntities; + } + + @Override + void initMapper() { + xmlMapper.addMixIn(EntitlementPoolEntity.class, + MixinEntitlementPoolEntityForVendorLicenseArtifact.class); + xmlMapper.addMixIn(LicenseKeyGroupEntity.class, + MixinLicenseKeyGroupEntityForVendorLicenseArtifact.class); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/VnfLicenseArtifact.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/VnfLicenseArtifact.java new file mode 100644 index 0000000000..1f8607765a --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/VnfLicenseArtifact.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T 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.openecomp.sdc.vendorlicense.licenseartifacts.impl.types; + +import com.ctc.wstx.api.WstxInputProperties; +import com.ctc.wstx.stax.WstxInputFactory; +import com.ctc.wstx.stax.WstxOutputFactory; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.XmlFactory; +import com.fasterxml.jackson.dataformat.xml.XmlMapper; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; +import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupModel; +import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; +import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinEntitlementPoolEntityForVnfArtifact; +import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinFeatureGroupModel; +import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinLicenseKeyGroupEntityForVnfArtifact; + +import java.io.Writer; +import java.util.ArrayList; +import java.util.List; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; + +@JacksonXmlRootElement(localName = "vf-license-model", + namespace = "http://xmlns.openecomp.org/asdc/license-model/1.0") +public class VnfLicenseArtifact extends XmlArtifact { + @JsonProperty(value = "vendor-name") + String vendorName; + @JsonProperty(value = "vf-id") + String vspId; + List<FeatureGroupModel> featureGroups = new ArrayList<>(); + + public String getVspId() { + return vspId; + } + + public void setVspId(String vspId) { + this.vspId = vspId; + } + + public String getVendorName() { + return vendorName; + } + + public void setVendorName(String vendorName) { + this.vendorName = vendorName; + } + + @JacksonXmlProperty(isAttribute = false, localName = "feature-group") + @JacksonXmlElementWrapper(localName = "feature-group-list") + public List<FeatureGroupModel> getFeatureGroups() { + return featureGroups; + } + + public void setFeatureGroups(List<FeatureGroupModel> featureGroups) { + this.featureGroups = featureGroups; + } + + void initMapper() { + WstxOutputFactory wstxOutputFactory = new WstxOutputFactory() { + @Override + public XMLStreamWriter createXMLStreamWriter(Writer writer) throws XMLStreamException { + mConfig.setProperty(WstxInputProperties.P_RETURN_NULL_FOR_DEFAULT_NAMESPACE, true); + return super.createXMLStreamWriter(writer); + } + }; + XmlFactory factory = new XmlFactory(new WstxInputFactory(), wstxOutputFactory); + + xmlMapper = new XmlMapper(factory); + + + xmlMapper.addMixIn(EntitlementPoolEntity.class, MixinEntitlementPoolEntityForVnfArtifact.class); + xmlMapper.addMixIn(LicenseKeyGroupEntity.class, MixinLicenseKeyGroupEntityForVnfArtifact.class); + xmlMapper.addMixIn(FeatureGroupModel.class, MixinFeatureGroupModel.class); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/XmlArtifact.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/XmlArtifact.java new file mode 100644 index 0000000000..78d5e22412 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/XmlArtifact.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T 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.openecomp.sdc.vendorlicense.licenseartifacts.impl.types; + +import com.fasterxml.jackson.dataformat.xml.XmlMapper; +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.vendorlicense.VendorLicenseConstants; +import org.openecomp.sdc.vendorlicense.errors.JsonErrorBuilder; + +public abstract class XmlArtifact { + + XmlMapper xmlMapper = new XmlMapper(); + + abstract void initMapper(); + + /** + * To xml string. + * + * @return the string + */ + public String toXml() { + initMapper(); + String xml = ""; + + try { + xml = xmlMapper.writeValueAsString(this); + } catch (com.fasterxml.jackson.core.JsonProcessingException jsonProcessingException) { + throw new CoreException(new JsonErrorBuilder(jsonProcessingException.getMessage()).build()); + + } + + return xml.replaceAll(VendorLicenseConstants.VENDOR_LICENSE_MODEL_ARTIFACT_REGEX_REMOVE, ""); + } + + +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinEntitlementPoolEntityForVendorLicenseArtifact.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinEntitlementPoolEntityForVendorLicenseArtifact.java new file mode 100644 index 0000000000..1458fa80a7 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinEntitlementPoolEntityForVendorLicenseArtifact.java @@ -0,0 +1,100 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T 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.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import org.openecomp.sdc.vendorlicense.dao.types.AggregationFunction; +import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther; +import org.openecomp.sdc.vendorlicense.dao.types.EntitlementMetric; +import org.openecomp.sdc.vendorlicense.dao.types.EntitlementTime; +import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope; +import org.openecomp.sdc.vendorlicense.dao.types.xml.AggregationFunctionForXml; +import org.openecomp.sdc.vendorlicense.dao.types.xml.EntitlementMetricForXml; +import org.openecomp.sdc.vendorlicense.dao.types.xml.EntitlementTimeForXml; +import org.openecomp.sdc.vendorlicense.dao.types.xml.ThresholdForXml; + +import java.util.Set; + +public abstract class MixinEntitlementPoolEntityForVendorLicenseArtifact { + @JsonProperty(value = "threshold-value") + abstract ThresholdForXml getThresholdForArtifact(); + + @JsonProperty(value = "entitlement-pool-uuid") + abstract String getVersionUuId(); + + @JsonProperty(value = "manufacturer-reference-number") + abstract String getManufacturerReferenceNumber(); + + @JsonIgnore + abstract Set<String> getReferencingFeatureGroups(); + + @JsonIgnore + abstract String getFirstClassCitizenId(); + + @JsonIgnore + abstract String getId(); + + @JsonIgnore + abstract String getVersion(); + + @JsonIgnore + abstract String getVendorLicenseModelId(); + + @JsonIgnore + abstract String getThresholdUnit(); + + @JsonIgnore + abstract float getThresholdValue(); + + @JsonIgnore + abstract ChoiceOrOther<EntitlementMetric> getEntitlementMetric(); + + @JsonIgnore + abstract ChoiceOrOther<EntitlementTime> getTime(); + + @JsonIgnore + abstract ChoiceOrOther<AggregationFunction> getAggregationFunction(); + + @JsonIgnore + abstract String getEntityType(); + + @JacksonXmlProperty(isAttribute = false, localName = "value") + @JacksonXmlElementWrapper(localName = "operational-scope") + abstract String getOperationalScopeForArtifact(); + + @JsonIgnore + abstract ChoiceOrOther<OperationalScope> getOperationalScope(); + + + @JsonProperty(value = "entitlement-metric") + abstract EntitlementMetricForXml getEntitlementMetricForArtifact(); + + @JsonProperty(value = "time") + abstract EntitlementTimeForXml getTimeForArtifact(); + + + @JsonProperty(value = "aggregation-function") + abstract AggregationFunctionForXml getAggregationFunctionForArtifact(); + +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinEntitlementPoolEntityForVnfArtifact.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinEntitlementPoolEntityForVnfArtifact.java new file mode 100644 index 0000000000..c4f2b4d4bd --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinEntitlementPoolEntityForVnfArtifact.java @@ -0,0 +1,100 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T 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.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import org.openecomp.sdc.vendorlicense.dao.types.AggregationFunction; +import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther; +import org.openecomp.sdc.vendorlicense.dao.types.EntitlementMetric; +import org.openecomp.sdc.vendorlicense.dao.types.EntitlementTime; +import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope; +import org.openecomp.sdc.vendorlicense.dao.types.xml.AggregationFunctionForXml; +import org.openecomp.sdc.vendorlicense.dao.types.xml.EntitlementMetricForXml; +import org.openecomp.sdc.vendorlicense.dao.types.xml.EntitlementTimeForXml; +import org.openecomp.sdc.vendorlicense.dao.types.xml.ThresholdForXml; + +import java.util.Set; + +public abstract class MixinEntitlementPoolEntityForVnfArtifact { + @JsonProperty(value = "threshold-value") + abstract ThresholdForXml getThresholdForArtifact(); + + @JsonIgnore + abstract String getId(); + + @JsonProperty(value = "manufacturer-reference-number") + abstract String getManufacturerReferenceNumber(); + + @JsonIgnore + abstract Set<String> getReferencingFeatureGroups(); + + @JsonIgnore + abstract String getFirstClassCitizenId(); + + @JsonProperty(value = "entitlement-pool-uuid") + abstract String getVersionUuId(); + + @JsonIgnore + abstract String getVersion(); + + @JsonIgnore + abstract String getVendorLicenseModelId(); + + @JsonIgnore + abstract String getThresholdUnit(); + + @JsonIgnore + abstract float getThresholdValue(); + + @JsonIgnore + abstract ChoiceOrOther<EntitlementMetric> getEntitlementMetric(); + + @JsonIgnore + abstract ChoiceOrOther<EntitlementTime> getTime(); + + @JsonIgnore + abstract ChoiceOrOther<AggregationFunction> getAggregationFunction(); + + @JsonIgnore + abstract String getEntityType(); + + @JacksonXmlProperty(isAttribute = false, localName = "value") + @JacksonXmlElementWrapper(localName = "operational-scope") + abstract String getOperationalScopeForArtifact(); + + @JsonIgnore + abstract ChoiceOrOther<OperationalScope> getOperationalScope(); + + + @JsonProperty(value = "entitlement-metric") + abstract EntitlementMetricForXml getEntitlementMetricForArtifact(); + + @JsonProperty(value = "time") + abstract EntitlementTimeForXml getTimeForArtifact(); + + + @JsonProperty(value = "aggregation-function") + abstract AggregationFunctionForXml getAggregationFunctionForArtifact(); + +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinFeatureGroupEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinFeatureGroupEntity.java new file mode 100644 index 0000000000..be6bd61357 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinFeatureGroupEntity.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T 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.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.util.Set; + +public abstract class MixinFeatureGroupEntity { + + @JsonIgnore + abstract String getVendorLicenseModelId(); + + @JsonIgnore + abstract String getEntityType(); + + + @JsonIgnore + abstract Version getVersion(); + + @JsonIgnore + abstract String getId(); + + @JsonIgnore + abstract String getName(); + + @JsonIgnore + abstract String getDescription(); + + @JsonIgnore + abstract String getPartNumber(); + + @JsonIgnore + abstract Set<String> getLicenseKeyGroupIds(); + + @JsonIgnore + abstract Set<String> getEntitlementPoolIds(); + + + @JsonIgnore + abstract Set<String> getReferencingLicenseAgreements(); + +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinFeatureGroupModel.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinFeatureGroupModel.java new file mode 100644 index 0000000000..1e76a74f4c --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinFeatureGroupModel.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T 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.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; +import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; +import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; + +import java.util.Set; + +public abstract class MixinFeatureGroupModel { + @JacksonXmlProperty(isAttribute = false, localName = "entitlement-pool") + @JacksonXmlElementWrapper(localName = "entitlement-pool-list") + abstract Set<EntitlementPoolEntity> getEntitlementPools(); + + @JacksonXmlProperty(isAttribute = false, localName = "license-key-group") + @JacksonXmlElementWrapper(localName = "license-key-group-list") + abstract Set<LicenseKeyGroupEntity> getLicenseKeyGroups(); + + @JacksonXmlProperty(isAttribute = false, localName = "internal-part-number") + abstract String getEntityPartNumber(); + + @JacksonXmlProperty(isAttribute = false, localName = "feature-group-uuid") + abstract String getEntityId(); + + @JacksonXmlProperty(isAttribute = false, localName = "description") + abstract String getEntityDesc(); + + @JacksonXmlProperty(isAttribute = false, localName = "name") + abstract String getEntityName(); + + + @JsonIgnore + abstract FeatureGroupEntity getFeatureGroup(); + + @JsonIgnore + abstract String getEntityType(); + + +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinLicenseKeyGroupEntityForVendorLicenseArtifact.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinLicenseKeyGroupEntityForVendorLicenseArtifact.java new file mode 100644 index 0000000000..ed3083afe3 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinLicenseKeyGroupEntityForVendorLicenseArtifact.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T 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.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther; +import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope; +import org.openecomp.sdc.vendorlicense.dao.types.xml.LicenseKeyTypeForXml; + +import java.util.Set; + +public abstract class MixinLicenseKeyGroupEntityForVendorLicenseArtifact { + @JsonProperty(value = "license-key-group-uuid") + abstract String getVersionUuId(); + + @JsonIgnore + abstract Set<String> getReferencingFeatureGroups(); + + @JsonIgnore + abstract String getVersion(); + + @JsonIgnore + abstract String getVendorLicenseModelId(); + + + @JsonIgnore + abstract String getEntityType(); + + @JsonIgnore + abstract String getFirstClassCitizenId(); + + @JsonIgnore + abstract String getId(); + + + @JsonIgnore + abstract ChoiceOrOther<OperationalScope> getOperationalScope(); + + @JacksonXmlProperty(isAttribute = false, localName = "value") + @JacksonXmlElementWrapper(localName = "operational-scope") + abstract String getOperationalScopeForArtifact(); + + + @JsonIgnore + abstract LicenseKeyTypeForXml getTypeForArtifact(); + + @JsonIgnore + abstract String getVersionableId(); + + +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinLicenseKeyGroupEntityForVnfArtifact.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinLicenseKeyGroupEntityForVnfArtifact.java new file mode 100644 index 0000000000..6281c44830 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinLicenseKeyGroupEntityForVnfArtifact.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T 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.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther; +import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope; +import org.openecomp.sdc.vendorlicense.dao.types.xml.LicenseKeyTypeForXml; + +import java.util.Set; + +public abstract class MixinLicenseKeyGroupEntityForVnfArtifact { + @JsonIgnore + abstract String getId(); + + @JsonIgnore + abstract Set<String> getReferencingFeatureGroups(); + + @JsonIgnore + abstract String getVersion(); + + @JsonIgnore + abstract String getVendorLicenseModelId(); + + + @JsonIgnore + abstract String getEntityType(); + + @JsonProperty(value = "license-key-group-uuid") + abstract String getVersionUuId(); + + @JsonIgnore + abstract String getFirstClassCitizenId(); + + + + @JsonIgnore + abstract ChoiceOrOther<OperationalScope> getOperationalScope(); + + @JacksonXmlProperty(isAttribute = false, localName = "value") + @JacksonXmlElementWrapper(localName = "operational-scope") + abstract String getOperationalScopeForArtifact(); + + + @JsonIgnore + abstract LicenseKeyTypeForXml getTypeForArtifact(); + + @JsonIgnore + abstract String getVersionableId(); + + +} + |