diff options
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src')
45 files changed, 2894 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/HealingServiceFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/HealingServiceFactory.java new file mode 100644 index 0000000000..19d664247b --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/HealingServiceFactory.java @@ -0,0 +1,32 @@ +/*- + * ============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; + +import org.openecomp.core.factory.api.AbstractComponentFactory; +import org.openecomp.core.factory.api.AbstractFactory; +import org.openecomp.sdc.vendorlicense.healing.HealingService; + +public abstract class HealingServiceFactory extends AbstractComponentFactory<HealingService> { + + public static HealingServiceFactory getInstance() { + return AbstractFactory.getInstance(HealingServiceFactory.class); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseArtifactServiceFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseArtifactServiceFactory.java new file mode 100644 index 0000000000..0ce7484aa7 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseArtifactServiceFactory.java @@ -0,0 +1,33 @@ +/*- + * ============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; + +import org.openecomp.core.factory.api.AbstractComponentFactory; +import org.openecomp.core.factory.api.AbstractFactory; +import org.openecomp.sdc.vendorlicense.licenseartifacts.VendorLicenseArtifactsService; + +public abstract class VendorLicenseArtifactServiceFactory + extends AbstractComponentFactory<VendorLicenseArtifactsService> { + + public static VendorLicenseArtifactServiceFactory getInstance() { + return AbstractFactory.getInstance(VendorLicenseArtifactServiceFactory.class); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseConstants.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseConstants.java new file mode 100644 index 0000000000..2a1930d626 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseConstants.java @@ -0,0 +1,43 @@ +/*- + * ============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; + +import java.io.File; + +public final class VendorLicenseConstants { + public static final String VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE = "VendorLicenseModel"; + + public static final String EXTERNAL_ARTIFACTS_DIR = "Artifacts"; + //todo change when separating external from internal artifacts + public static final String VNF_ARTIFACT_NAME_WITH_PATH = + EXTERNAL_ARTIFACTS_DIR + File.separator + "vf-license-model.xml"; + public static final String VENDOR_LICENSE_MODEL_ARTIFACT_NAME_WITH_PATH = + EXTERNAL_ARTIFACTS_DIR + File.separator + "vendor-license-model.xml"; + public static final String VENDOR_LICENSE_MODEL_ARTIFACT_REGEX_REMOVE = " xmlns=\"\""; + + public final class UniqueValues { + public static final String VENDOR_NAME = "Vendor name"; + public static final String LICENSE_AGREEMENT_NAME = "License Agreement name"; + public static final String FEATURE_GROUP_NAME = "Feature Group name"; + public static final String ENTITLEMENT_POOL_NAME = "Entitlement Pool name"; + public static final String LICENSE_KEY_GROUP_NAME = "License Key Group name"; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/EntitlementPoolDao.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/EntitlementPoolDao.java new file mode 100644 index 0000000000..c507e6946a --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/EntitlementPoolDao.java @@ -0,0 +1,38 @@ +/*- + * ============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.dao; + +import org.openecomp.core.dao.BaseDao; +import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; +import org.openecomp.sdc.versioning.dao.VersionableDao; + +public interface EntitlementPoolDao extends VersionableDao, BaseDao<EntitlementPoolEntity> { + + long count(EntitlementPoolEntity entitlementPool); + + void deleteAll(EntitlementPoolEntity entitlementPool); + + void addReferencingFeatureGroup(EntitlementPoolEntity entitlementPool, + String referencingFeatureGroupId); + + void removeReferencingFeatureGroup(EntitlementPoolEntity entitlementPool, + String referencingFeatureGroupId); +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/EntitlementPoolDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/EntitlementPoolDaoFactory.java new file mode 100644 index 0000000000..e5bfcfa1cb --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/EntitlementPoolDaoFactory.java @@ -0,0 +1,31 @@ +/*- + * ============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.dao; + +import org.openecomp.core.factory.api.AbstractComponentFactory; +import org.openecomp.core.factory.api.AbstractFactory; + +public abstract class EntitlementPoolDaoFactory + extends AbstractComponentFactory<EntitlementPoolDao> { + public static EntitlementPoolDaoFactory getInstance() { + return AbstractFactory.getInstance(EntitlementPoolDaoFactory.class); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/FeatureGroupDao.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/FeatureGroupDao.java new file mode 100644 index 0000000000..a5db802861 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/FeatureGroupDao.java @@ -0,0 +1,47 @@ +/*- + * ============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.dao; + +import org.openecomp.core.dao.BaseDao; +import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; +import org.openecomp.sdc.versioning.dao.VersionableDao; + +import java.util.Set; + +public interface FeatureGroupDao extends VersionableDao, BaseDao<FeatureGroupEntity> { + + long count(FeatureGroupEntity featureGroup); + + void deleteAll(FeatureGroupEntity featureGroup); + + void updateFeatureGroup(FeatureGroupEntity entity, Set<String> addedEntitlementPools, + Set<String> removedEntitlementPools, Set<String> addedLicenseKeyGroups, + Set<String> removedLicenseKeyGroups); + + void addReferencingLicenseAgreement(FeatureGroupEntity featureGroup, String licenseAgreementId); + + void removeReferencingLicenseAgreement(FeatureGroupEntity featureGroup, + String licenseAgreementId); + + void removeEntitlementPool(FeatureGroupEntity featureGroup, String entitlementPoolId); + + void removeLicenseKeyGroup(FeatureGroupEntity featureGroup, String licenseKeyGroupId); +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/FeatureGroupDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/FeatureGroupDaoFactory.java new file mode 100644 index 0000000000..58832e12ae --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/FeatureGroupDaoFactory.java @@ -0,0 +1,31 @@ +/*- + * ============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.dao; + +import org.openecomp.core.factory.api.AbstractComponentFactory; +import org.openecomp.core.factory.api.AbstractFactory; + + +public abstract class FeatureGroupDaoFactory extends AbstractComponentFactory<FeatureGroupDao> { + public static FeatureGroupDaoFactory getInstance() { + return AbstractFactory.getInstance(FeatureGroupDaoFactory.class); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseAgreementDao.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseAgreementDao.java new file mode 100644 index 0000000000..df5e972422 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseAgreementDao.java @@ -0,0 +1,40 @@ +/*- + * ============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.dao; + +import org.openecomp.core.dao.BaseDao; +import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity; +import org.openecomp.sdc.versioning.dao.VersionableDao; + +import java.util.Set; + +public interface LicenseAgreementDao extends VersionableDao, BaseDao<LicenseAgreementEntity> { + + long count(LicenseAgreementEntity entity); + + void deleteAll(LicenseAgreementEntity entity); + + void removeFeatureGroup(LicenseAgreementEntity licenseAgreement, String featureGroupId); + + void updateColumnsAndDeltaFeatureGroupIds(LicenseAgreementEntity licenseAgreement, + Set<String> addedFeatureGroupIds, + Set<String> removedFeatureGroupIds); +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseAgreementDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseAgreementDaoFactory.java new file mode 100644 index 0000000000..54c7b7bfea --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseAgreementDaoFactory.java @@ -0,0 +1,31 @@ +/*- + * ============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.dao; + +import org.openecomp.core.factory.api.AbstractComponentFactory; +import org.openecomp.core.factory.api.AbstractFactory; + +public abstract class LicenseAgreementDaoFactory + extends AbstractComponentFactory<LicenseAgreementDao> { + public static LicenseAgreementDaoFactory getInstance() { + return AbstractFactory.getInstance(LicenseAgreementDaoFactory.class); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseKeyGroupDao.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseKeyGroupDao.java new file mode 100644 index 0000000000..43e380d9b9 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseKeyGroupDao.java @@ -0,0 +1,34 @@ +/*- + * ============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.dao; + +import org.openecomp.core.dao.BaseDao; +import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; +import org.openecomp.sdc.versioning.dao.VersionableDao; + +public interface LicenseKeyGroupDao extends VersionableDao, BaseDao<LicenseKeyGroupEntity> { + + void deleteAll(LicenseKeyGroupEntity licenseKeyGroup); + + void addReferencingFeatureGroup(LicenseKeyGroupEntity licenseKeyGroup, String featureGroupId); + + void removeReferencingFeatureGroup(LicenseKeyGroupEntity licenseKeyGroup, String featureGroupId); +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseKeyGroupDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseKeyGroupDaoFactory.java new file mode 100644 index 0000000000..1f887390db --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseKeyGroupDaoFactory.java @@ -0,0 +1,32 @@ +/*- + * ============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.dao; + +import org.openecomp.core.factory.api.AbstractComponentFactory; +import org.openecomp.core.factory.api.AbstractFactory; + +public abstract class LicenseKeyGroupDaoFactory + extends AbstractComponentFactory<LicenseKeyGroupDao> { + + public static LicenseKeyGroupDaoFactory getInstance() { + return AbstractFactory.getInstance(LicenseKeyGroupDaoFactory.class); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/VendorLicenseModelDao.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/VendorLicenseModelDao.java new file mode 100644 index 0000000000..b8e39bc496 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/VendorLicenseModelDao.java @@ -0,0 +1,29 @@ +/*- + * ============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.dao; + +import org.openecomp.core.dao.BaseDao; +import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity; +import org.openecomp.sdc.versioning.dao.VersionableDao; + +public interface VendorLicenseModelDao extends VersionableDao, BaseDao<VendorLicenseModelEntity> { +// void updateLastModificationTime(VendorLicenseModelEntity vendorLicenseModel); +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/VendorLicenseModelDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/VendorLicenseModelDaoFactory.java new file mode 100644 index 0000000000..b6d13a9027 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/VendorLicenseModelDaoFactory.java @@ -0,0 +1,32 @@ +/*- + * ============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.dao; + +import org.openecomp.core.factory.api.AbstractComponentFactory; +import org.openecomp.core.factory.api.AbstractFactory; + +public abstract class VendorLicenseModelDaoFactory + extends AbstractComponentFactory<VendorLicenseModelDao> { + + public static VendorLicenseModelDaoFactory getInstance() { + return AbstractFactory.getInstance(VendorLicenseModelDaoFactory.class); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/AggregationFunction.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/AggregationFunction.java new file mode 100644 index 0000000000..9a5af213c4 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/AggregationFunction.java @@ -0,0 +1,27 @@ +/*- + * ============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.dao.types; + +public enum AggregationFunction { + Peak, + Average, + Other +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/ChoiceOrOther.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/ChoiceOrOther.java new file mode 100644 index 0000000000..ca7a09b0df --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/ChoiceOrOther.java @@ -0,0 +1,154 @@ +/*- + * ============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.dao.types; + +import com.datastax.driver.mapping.annotations.Transient; +import com.datastax.driver.mapping.annotations.UDT; +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.common.errors.ErrorCategory; +import org.openecomp.sdc.common.errors.ErrorCode; + +@UDT(keyspace = "dox", name = "choice_or_other") +public class ChoiceOrOther<E extends Enum<E>> { + + public static final String CHOICE_OR_OTHER_INVALID_ENUM_ERR_ID = + "MULTI_CHOICE_OR_OTHER_INVALID_ENUM_ERR_ID"; + public static final String CHOICE_OR_OTHER_INVALID_ENUM_MSG = + "Enum used as part of ChoiceOrOther type must contain the value 'Other'"; + public static final String OTHER_ENUM_VALUE = "Other"; + + @Transient + private E choice; + + @Transient + private String other; + + private String result; + + public ChoiceOrOther() { + } + + /** + * Instantiates a new Choice or other. + * + * @param choice the choice + * @param other the other + */ + public ChoiceOrOther(E choice, String other) { + this.choice = choice; + this.other = other; + result = resolveResult(); + } + + public E getChoice() { + return choice; + } + + public void setChoice(E choice) { + + this.choice = choice; + } + + public String getOther() { + return other; + } + + public void setOther(String other) { + this.other = other; + } + + public String getResult() { + return result; + } + + /** + * Sets result. + * + * @param result the result + */ + public void setResult(String result) { + if (choice != null) { + if (result == null) { + this.result = resolveResult(); + } + } else { + this.result = result; + } + } + + private String resolveResult() { + return OTHER_ENUM_VALUE.equals(choice.name()) ? other : choice.name(); + } + + /** + * Resolve enum. + * + * @param enumClass the enum class + */ + public void resolveEnum(Class<E> enumClass) { + if (choice != null || result == null) { + return; + } + + try { + choice = E.valueOf(enumClass, result); + } catch (IllegalArgumentException e0) { + try { + choice = E.valueOf(enumClass, OTHER_ENUM_VALUE); + } catch (IllegalArgumentException ex) { + throw new CoreException(new ErrorCode.ErrorCodeBuilder() + .withId(CHOICE_OR_OTHER_INVALID_ENUM_ERR_ID) + .withMessage(CHOICE_OR_OTHER_INVALID_ENUM_MSG) + .withCategory(ErrorCategory.APPLICATION).build()); + } + other = result; + } + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + + ChoiceOrOther<?> that = (ChoiceOrOther<?>) obj; + + if (choice != null ? !choice.equals(that.choice) : that.choice != null) { + return false; + } + if (other != null ? !other.equals(that.other) : that.other != null) { + return false; + } + return result != null ? result.equals(that.result) : that.result == null; + + } + + @Override + public int hashCode() { + int result1 = choice != null ? choice.hashCode() : 0; + result1 = 31 * result1 + (other != null ? other.hashCode() : 0); + result1 = 31 * result1 + (result != null ? result.hashCode() : 0); + return result1; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementMetric.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementMetric.java new file mode 100644 index 0000000000..42cc231273 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementMetric.java @@ -0,0 +1,37 @@ +/*- + * ============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.dao.types; + +public enum EntitlementMetric { + Software_Instances_Count, + Core, + CPU, + Trunks, + User, + Subscribers, + Tenants, + Tokens, + Seats, + Units_TB, + Units_MB, + Units_GB, + Other +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementPoolEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementPoolEntity.java new file mode 100644 index 0000000000..8964458181 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementPoolEntity.java @@ -0,0 +1,370 @@ +/*- + * ============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.dao.types; + +import com.datastax.driver.mapping.annotations.ClusteringColumn; +import com.datastax.driver.mapping.annotations.Column; +import com.datastax.driver.mapping.annotations.Enumerated; +import com.datastax.driver.mapping.annotations.Frozen; +import com.datastax.driver.mapping.annotations.PartitionKey; +import com.datastax.driver.mapping.annotations.Table; +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 org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.dao.types.VersionableEntity; + +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +@Table(keyspace = "dox", name = "entitlement_pool") +public class EntitlementPoolEntity implements VersionableEntity { + private static final String ENTITY_TYPE = "Entitlement Pool"; + + @PartitionKey + @Column(name = "vlm_id") + private String vendorLicenseModelId; + + @PartitionKey(value = 1) + @Frozen + private Version version; + + @ClusteringColumn + @Column(name = "ep_id") + private String id; + private String name; + private String description; + + + @Column(name = "threshold") + private int thresholdValue; + + @Column(name = "threshold_unit") + @Enumerated + private ThresholdUnit thresholdUnit; + + @Column(name = "entitlement_metric") + @Frozen + private ChoiceOrOther<EntitlementMetric> entitlementMetric; + private String increments; + + @Column(name = "aggregation_func") + @Frozen + private ChoiceOrOther<AggregationFunction> aggregationFunction; + + @Column(name = "operational_scope") + @Frozen + private MultiChoiceOrOther<OperationalScope> operationalScope; + + @Frozen + private ChoiceOrOther<EntitlementTime> time; + + @Column(name = "manufacturer_ref_num") + private String manufacturerReferenceNumber; + + @Column(name = "ref_fg_ids") + private Set<String> referencingFeatureGroups = new HashSet<>(); + + @Column(name = "version_uuid") + private String versionUuId; + + public EntitlementPoolEntity() { + } + + /** + * Instantiates a new Entitlement pool entity. + * + * @param vlmId the vlm id + * @param version the version + * @param id the id + */ + public EntitlementPoolEntity(String vlmId, Version version, String id) { + this.vendorLicenseModelId = vlmId; + this.version = version; + this.id = id; + } + + @Override + public String getEntityType() { + return ENTITY_TYPE; + } + + @Override + public String getFirstClassCitizenId() { + return getVendorLicenseModelId(); + } + + public String getVendorLicenseModelId() { + return vendorLicenseModelId; + } + + public void setVendorLicenseModelId(String vendorLicenseModelId) { + this.vendorLicenseModelId = vendorLicenseModelId; + } + + @Override + public String getId() { + return id; + } + + @Override + public void setId(String id) { + this.id = id; + } + + @Override + public Version getVersion() { + return version; + } + + @Override + public void setVersion(Version version) { + this.version = version; + } + + public Set<String> getReferencingFeatureGroups() { + return referencingFeatureGroups; + } + + public void setReferencingFeatureGroups(Set<String> referencingFeatureGroups) { + this.referencingFeatureGroups = referencingFeatureGroups; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getThresholdValue() { + return thresholdValue; + } + + public void setThresholdValue(int thresholdValue) { + this.thresholdValue = thresholdValue; + } + + public ThresholdUnit getThresholdUnit() { + return thresholdUnit; + } + + public void setThresholdUnit(ThresholdUnit thresholdUnits) { + this.thresholdUnit = thresholdUnits; + } + + public ChoiceOrOther<EntitlementMetric> getEntitlementMetric() { + return entitlementMetric; + } + + public void setEntitlementMetric(ChoiceOrOther<EntitlementMetric> entitlementMetric) { + entitlementMetric.resolveEnum(EntitlementMetric.class); + this.entitlementMetric = entitlementMetric; + } + + public String getIncrements() { + return increments; + } + + public void setIncrements(String increments) { + this.increments = increments; + } + + public ChoiceOrOther<AggregationFunction> getAggregationFunction() { + return aggregationFunction; + } + + public void setAggregationFunction(ChoiceOrOther<AggregationFunction> aggregationFunction) { + aggregationFunction.resolveEnum(AggregationFunction.class); + this.aggregationFunction = aggregationFunction; + } + + public MultiChoiceOrOther<OperationalScope> getOperationalScope() { + return operationalScope; + } + + public void setOperationalScope(MultiChoiceOrOther<OperationalScope> operationalScope) { + operationalScope.resolveEnum(OperationalScope.class); + this.operationalScope = operationalScope; + } + + public ChoiceOrOther<EntitlementTime> getTime() { + return time; + } + + public void setTime(ChoiceOrOther<EntitlementTime> time) { + time.resolveEnum(EntitlementTime.class); + this.time = time; + } + + public String getManufacturerReferenceNumber() { + return manufacturerReferenceNumber; + } + + public void setManufacturerReferenceNumber(String manufacturerReferenceNumber) { + this.manufacturerReferenceNumber = manufacturerReferenceNumber; + } + + + /** + * Gets threshold for artifact. + * + * @return the threshold for artifact + */ + //util methods for XML + public ThresholdForXml getThresholdForArtifact() { + ThresholdForXml threshold = new ThresholdForXml(); + threshold.setUnit(getThresholdUnit() == null ? null : getThresholdUnit().name()); + threshold.setValue(getThresholdValue()); + return threshold; + } + + /** + * Gets entitlement metric for artifact. + * + * @return the entitlement metric for artifact + */ + public EntitlementMetricForXml getEntitlementMetricForArtifact() { + EntitlementMetricForXml metric = new EntitlementMetricForXml(); + if (entitlementMetric != null) { + metric.setValue(entitlementMetric.getResult()); + } else { + metric.setValue(null); + } + return metric; + } + + /** + * Gets time for artifact. + * + * @return the time for artifact + */ + public EntitlementTimeForXml getTimeForArtifact() { + EntitlementTimeForXml timeForXml = new EntitlementTimeForXml(); + if (time != null) { + timeForXml.setValue(time.getResult()); + } + + return timeForXml; + } + + + @Override + public String toString() { + return "EntitlementPoolEntity{" + + "vendorLicenseModelId='" + vendorLicenseModelId + '\'' + + ", version=" + version + + ", id='" + id + '\'' + + ", name='" + name + '\'' + + ", description='" + description + '\'' + + ", thresholdValue=" + thresholdValue + + ", thresholdUnit='" + thresholdUnit + '\'' + + ", entitlementMetric=" + entitlementMetric + + ", increments='" + increments + '\'' + + ", aggregationFunction=" + aggregationFunction + + ", operationalScope=" + operationalScope + + ", time=" + time + + ", manufacturerReferenceNumber='" + manufacturerReferenceNumber + '\'' + + ", referencingFeatureGroups=" + referencingFeatureGroups + + ", version_uuid=" + versionUuId + + '}'; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + EntitlementPoolEntity that = (EntitlementPoolEntity) obj; + return Float.compare(that.thresholdValue, thresholdValue) == 0 + && Objects.equals(vendorLicenseModelId, that.vendorLicenseModelId) + && Objects.equals(version, that.version) + && Objects.equals(id, that.id) + && Objects.equals(name, that.name) + && Objects.equals(description, that.description) + && Objects.equals(thresholdUnit, that.thresholdUnit) + && Objects.equals(entitlementMetric, that.entitlementMetric) + && Objects.equals(increments, that.increments) + && Objects.equals(aggregationFunction, that.aggregationFunction) + && Objects.equals(operationalScope, that.operationalScope) + && Objects.equals(time, that.time) + && Objects.equals(manufacturerReferenceNumber, that.manufacturerReferenceNumber) + && Objects.equals(referencingFeatureGroups, that.referencingFeatureGroups); + } + + @Override + public int hashCode() { + return Objects + .hash(vendorLicenseModelId, version, id, name, description, thresholdValue, thresholdUnit, + entitlementMetric, increments, aggregationFunction, operationalScope, time, + manufacturerReferenceNumber, referencingFeatureGroups); + } + + /** + * Gets aggregation function for artifact. + * + * @return the aggregation function for artifact + */ + public AggregationFunctionForXml getAggregationFunctionForArtifact() { + AggregationFunctionForXml aggregationFunctionForXml = new AggregationFunctionForXml(); + if (entitlementMetric != null) { + aggregationFunctionForXml.setValue(aggregationFunction.getResult()); + } else { + aggregationFunctionForXml.setValue(null); + } + return aggregationFunctionForXml; + } + + /** + * Gets operational scope for artifact. + * + * @return the operational scope for artifact + */ + public Set<String> getOperationalScopeForArtifact() { + if (operationalScope != null) { + return operationalScope.getResults(); + } else { + return null; + } + } + + public String getVersionUuId() { + return versionUuId; + } + + public void setVersionUuId(String uuId) { + versionUuId = uuId; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementTime.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementTime.java new file mode 100644 index 0000000000..5005075122 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementTime.java @@ -0,0 +1,30 @@ +/*- + * ============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.dao.types; + +public enum EntitlementTime { //TODO MetricTime ? ask Segev... + Hour, + Day, + Month, + Quarter, + Year, + Other +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/FeatureGroupEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/FeatureGroupEntity.java new file mode 100644 index 0000000000..de5bd2e1c5 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/FeatureGroupEntity.java @@ -0,0 +1,203 @@ +/*- + * ============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.dao.types; + +import com.datastax.driver.mapping.annotations.ClusteringColumn; +import com.datastax.driver.mapping.annotations.Column; +import com.datastax.driver.mapping.annotations.Frozen; +import com.datastax.driver.mapping.annotations.PartitionKey; +import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.dao.types.VersionableEntity; + + +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +@Table(name = "feature_group", keyspace = "dox") +public class FeatureGroupEntity implements VersionableEntity { + private static final String ENTITY_TYPE = "Feature Group"; + + @PartitionKey + @Column(name = "vlm_id") + private String vendorLicenseModelId; + @PartitionKey(value = 1) + @Frozen + private Version version; + @ClusteringColumn + @Column(name = "fg_id") + private String id; + private String name; + private String description; + @Column(name = "part_num") + private String partNumber; + @Column(name = "lkg_ids") + private Set<String> licenseKeyGroupIds = new HashSet<>(); + @Column(name = "ep_ids") + private Set<String> entitlementPoolIds = new HashSet<>(); + @Column(name = "ref_la_ids") + private Set<String> referencingLicenseAgreements = new HashSet<>(); + + public FeatureGroupEntity() { + } + + /** + * Instantiates a new Feature group entity. + * + * @param vendorLicenseModelId the vendor license model id + * @param version the version + * @param id the id + */ + public FeatureGroupEntity(String vendorLicenseModelId, Version version, String id) { + this.vendorLicenseModelId = vendorLicenseModelId; + this.version = version; + this.id = id; + } + + @Override + public String getEntityType() { + return ENTITY_TYPE; + } + + @Override + public String getFirstClassCitizenId() { + return getVendorLicenseModelId(); + } + + public String getVendorLicenseModelId() { + return vendorLicenseModelId; + } + + public void setVendorLicenseModelId(String vendorLicenseModelId) { + this.vendorLicenseModelId = vendorLicenseModelId; + } + + @Override + public Version getVersion() { + return version; + } + + @Override + public void setVersion(Version version) { + this.version = version; + } + + @Override + public String getId() { + return id; + } + + @Override + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getPartNumber() { + return partNumber; + } + + public void setPartNumber(String partNumber) { + this.partNumber = partNumber; + } + + public Set<String> getLicenseKeyGroupIds() { + return licenseKeyGroupIds; + } + + public void setLicenseKeyGroupIds(Set<String> licenseKeyGroupIds) { + this.licenseKeyGroupIds = licenseKeyGroupIds; + } + + public Set<String> getEntitlementPoolIds() { + return entitlementPoolIds; + } + + public void setEntitlementPoolIds(Set<String> entitlementPoolIds) { + this.entitlementPoolIds = entitlementPoolIds; + } + + public Set<String> getReferencingLicenseAgreements() { + return referencingLicenseAgreements; + } + + public void setReferencingLicenseAgreements(Set<String> referencingLicenseAgreements) { + this.referencingLicenseAgreements = referencingLicenseAgreements; + } + + @Override + public String toString() { + return "FeatureGroupEntity{" + + "vendorLicenseModelId='" + vendorLicenseModelId + '\'' + + ", version=" + version + + ", id='" + id + '\'' + + ", name='" + name + '\'' + + ", description='" + description + '\'' + + ", partNumber='" + partNumber + '\'' + + ", licenseKeyGroupIds=" + licenseKeyGroupIds + + ", entitlementPoolIds=" + entitlementPoolIds + + ", referencingLicenseAgreements=" + referencingLicenseAgreements + + '}'; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + FeatureGroupEntity that = (FeatureGroupEntity) obj; + return Objects.equals(vendorLicenseModelId, that.vendorLicenseModelId) + && Objects.equals(version, that.version) + && Objects.equals(id, that.id) + && Objects.equals(name, that.name) + && Objects.equals(description, that.description) + && Objects.equals(partNumber, that.partNumber) + && Objects.equals(licenseKeyGroupIds, that.licenseKeyGroupIds) + && Objects.equals(entitlementPoolIds, that.entitlementPoolIds) + && Objects.equals(referencingLicenseAgreements, that.referencingLicenseAgreements); + } + + @Override + public int hashCode() { + return Objects + .hash(vendorLicenseModelId, version, id, name, description, partNumber, licenseKeyGroupIds, + entitlementPoolIds, referencingLicenseAgreements); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/FeatureGroupModel.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/FeatureGroupModel.java new file mode 100644 index 0000000000..78e081760c --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/FeatureGroupModel.java @@ -0,0 +1,75 @@ +/*- + * ============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.dao.types; + +import java.util.HashSet; +import java.util.Set; + +public class FeatureGroupModel { + private FeatureGroupEntity featureGroup; + private Set<EntitlementPoolEntity> entitlementPools = new HashSet<>(); + + private Set<LicenseKeyGroupEntity> licenseKeyGroups = new HashSet<>(); + + public FeatureGroupEntity getFeatureGroup() { + return featureGroup; + } + + public void setFeatureGroup(FeatureGroupEntity featureGroup) { + this.featureGroup = featureGroup; + } + + public Set<EntitlementPoolEntity> getEntitlementPools() { + return entitlementPools; + } + + public Set<LicenseKeyGroupEntity> getLicenseKeyGroups() { + return licenseKeyGroups; + } + + public void setEntitlementPools(Set<EntitlementPoolEntity> entitlementPools) { + this.entitlementPools = entitlementPools; + } + + public void setLicenseKeyGroups(Set<LicenseKeyGroupEntity> licenseKeyGroups) { + this.licenseKeyGroups = licenseKeyGroups; + } + + //for XML Artifact + public String getEntityName() { + return featureGroup.getName(); + } + + public String getEntityDesc() { + return featureGroup.getDescription(); + } + + public String getEntityId() { + return featureGroup.getId(); + } + + public String getEntityPartNumber() { + return featureGroup.getPartNumber(); + } + + +} + diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseAgreementEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseAgreementEntity.java new file mode 100644 index 0000000000..a6e46bf44c --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseAgreementEntity.java @@ -0,0 +1,182 @@ +/*- + * ============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.dao.types; + +import com.datastax.driver.mapping.annotations.ClusteringColumn; +import com.datastax.driver.mapping.annotations.Column; +import com.datastax.driver.mapping.annotations.Frozen; +import com.datastax.driver.mapping.annotations.PartitionKey; +import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.dao.types.VersionableEntity; + +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +@Table(keyspace = "dox", name = "license_agreement") +public class LicenseAgreementEntity implements VersionableEntity { + public static final String ENTITY_TYPE = "License Agreement"; + + @PartitionKey(value = 0) + @Column(name = "vlm_id") + private String vendorLicenseModelId; + + @PartitionKey(value = 1) + @Frozen + private Version version; + + @ClusteringColumn + @Column(name = "la_id") + private String id; + private String name; + private String description; + + @Column(name = "lic_term") + @Frozen + private ChoiceOrOther<LicenseTerm> licenseTerm; + + @Column(name = "req_const") + private String requirementsAndConstrains; + + @Column(name = "fg_ids") + private Set<String> featureGroupIds = new HashSet<>(); + + public LicenseAgreementEntity() { + } + + /** + * Instantiates a new License agreement entity. + * + * @param vlmId the vlm id + * @param version the version + * @param id the id + */ + public LicenseAgreementEntity(String vlmId, Version version, String id) { + this.vendorLicenseModelId = vlmId; + this.id = id; + this.version = version; + } + + @Override + public String getEntityType() { + return ENTITY_TYPE; + } + + @Override + public String getFirstClassCitizenId() { + return getVendorLicenseModelId(); + } + + public String getVendorLicenseModelId() { + return vendorLicenseModelId; + } + + public void setVendorLicenseModelId(String vendorLicenseModelId) { + this.vendorLicenseModelId = vendorLicenseModelId; + } + + @Override + public Version getVersion() { + return version; + } + + @Override + public void setVersion(Version version) { + this.version = version; + } + + @Override + public String getId() { + return id; + } + + @Override + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public ChoiceOrOther<LicenseTerm> getLicenseTerm() { + return licenseTerm; + } + + public void setLicenseTerm(ChoiceOrOther<LicenseTerm> licenseTerm) { + licenseTerm.resolveEnum(LicenseTerm.class); + this.licenseTerm = licenseTerm; + } + + public String getRequirementsAndConstrains() { + return requirementsAndConstrains; + } + + public void setRequirementsAndConstrains(String requirementsAndConstrains) { + this.requirementsAndConstrains = requirementsAndConstrains; + } + + public Set<String> getFeatureGroupIds() { + return featureGroupIds; + } + + public void setFeatureGroupIds(Set<String> featureGroupIds) { + this.featureGroupIds = featureGroupIds; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + LicenseAgreementEntity that = (LicenseAgreementEntity) obj; + return Objects.equals(vendorLicenseModelId, that.vendorLicenseModelId) + && Objects.equals(version, that.version) + && Objects.equals(id, that.id) + && Objects.equals(name, that.name) + && Objects.equals(description, that.description) + && Objects.equals(licenseTerm, that.licenseTerm) + && Objects.equals(requirementsAndConstrains, that.requirementsAndConstrains) + && Objects.equals(featureGroupIds, that.featureGroupIds); + } + + @Override + public int hashCode() { + return Objects.hash(vendorLicenseModelId, version, id, name, description, licenseTerm, + requirementsAndConstrains, featureGroupIds); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseAgreementModel.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseAgreementModel.java new file mode 100644 index 0000000000..1e65f70cc0 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseAgreementModel.java @@ -0,0 +1,45 @@ +/*- + * ============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.dao.types; + +import java.util.HashSet; +import java.util.Set; + +public class LicenseAgreementModel { + private LicenseAgreementEntity licenseAgreement; + private Set<FeatureGroupEntity> featureGroups = new HashSet<>(); + + public LicenseAgreementEntity getLicenseAgreement() { + return licenseAgreement; + } + + public void setLicenseAgreement(LicenseAgreementEntity licenseAgreement) { + this.licenseAgreement = licenseAgreement; + } + + public Set<FeatureGroupEntity> getFeatureGroups() { + return featureGroups; + } + + public void setFeatureGroups(Set<FeatureGroupEntity> featureGroups) { + this.featureGroups = featureGroups; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseKeyGroupEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseKeyGroupEntity.java new file mode 100644 index 0000000000..2a7e936cb3 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseKeyGroupEntity.java @@ -0,0 +1,231 @@ +/*- + * ============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.dao.types; + +import com.datastax.driver.mapping.annotations.ClusteringColumn; +import com.datastax.driver.mapping.annotations.Column; +import com.datastax.driver.mapping.annotations.Enumerated; +import com.datastax.driver.mapping.annotations.Frozen; +import com.datastax.driver.mapping.annotations.PartitionKey; +import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.vendorlicense.dao.types.xml.LicenseKeyTypeForXml; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.dao.types.VersionableEntity; + + +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +@Table(keyspace = "dox", name = "license_key_group") +public class LicenseKeyGroupEntity implements VersionableEntity { + private static final String ENTITY_TYPE = "License Key Group"; + + @PartitionKey + @Column(name = "vlm_id") + private String vendorLicenseModelId; + @PartitionKey(value = 1) + @Frozen + private Version version; + @ClusteringColumn + @Column(name = "lkg_id") + private String id; + private String name; + private String description; + @Enumerated + private LicenseKeyType type; + @Column(name = "operational_scope") + @Frozen + private MultiChoiceOrOther<OperationalScope> operationalScope; + @Column(name = "ref_fg_ids") + private Set<String> referencingFeatureGroups = new HashSet<>(); + @Column(name = "version_uuid") + private String versionUuId; + + + public LicenseKeyGroupEntity() { + } + + /** + * Instantiates a new License key group entity. + * + * @param vendorLicenseModelId the vendor license model id + * @param version the version + * @param id the id + */ + public LicenseKeyGroupEntity(String vendorLicenseModelId, Version version, String id) { + this.vendorLicenseModelId = vendorLicenseModelId; + this.version = version; + this.id = id; + } + + @Override + public String getEntityType() { + return ENTITY_TYPE; + } + + @Override + public String getFirstClassCitizenId() { + return getVendorLicenseModelId(); + } + + public String getVendorLicenseModelId() { + return vendorLicenseModelId; + } + + public void setVendorLicenseModelId(String vendorLicenseModelId) { + this.vendorLicenseModelId = vendorLicenseModelId; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Version getVersion() { + return version; + } + + public void setVersion(Version version) { + this.version = version; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public LicenseKeyType getType() { + return type; + } + + public void setType(LicenseKeyType type) { + this.type = type; + } + + public MultiChoiceOrOther<OperationalScope> getOperationalScope() { + return operationalScope; + } + + public void setOperationalScope(MultiChoiceOrOther<OperationalScope> operationalScope) { + operationalScope.resolveEnum(OperationalScope.class); + this.operationalScope = operationalScope; + } + + public Set<String> getReferencingFeatureGroups() { + return referencingFeatureGroups; + } + + public void setReferencingFeatureGroups(Set<String> referencingFeatureGroups) { + this.referencingFeatureGroups = referencingFeatureGroups; + } + + @Override + public String toString() { + return "LicenseKeyGroupEntity{" + "vendorLicenseModelId='" + vendorLicenseModelId + '\'' + + ", version=" + version + + ", id='" + id + '\'' + + ", name='" + name + '\'' + + ", description='" + description + '\'' + + ", type=" + type + + ", operationalScope=" + operationalScope + + ", referencingFeatureGroups=" + referencingFeatureGroups + + ", versionUuId='" + versionUuId + '\'' + + '}'; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + LicenseKeyGroupEntity that = (LicenseKeyGroupEntity) obj; + return Objects.equals(vendorLicenseModelId, that.vendorLicenseModelId) + && Objects.equals(version, that.version) + && Objects.equals(id, that.id) + && Objects.equals(name, that.name) + && Objects.equals(description, that.description) + && type == that.type + && Objects.equals(operationalScope, that.operationalScope) + && Objects.equals(referencingFeatureGroups, that.referencingFeatureGroups); + } + + @Override + public int hashCode() { + return Objects + .hash(vendorLicenseModelId, version, id, name, description, type, operationalScope, + referencingFeatureGroups); + } + + /** + * Gets operational scope for artifact. + * + * @return the operational scope for artifact + */ + public Set<String> getOperationalScopeForArtifact() { + if (operationalScope != null) { + return operationalScope.getResults(); + } else { + return null; + } + } + + /** + * Gets type for artifact. + * + * @return the type for artifact + */ + public LicenseKeyTypeForXml getTypeForArtifact() { + LicenseKeyTypeForXml typeXml = new LicenseKeyTypeForXml(); + if (type != null) { + typeXml.setValue(type.toString()); + } else { + typeXml.setValue(null); + } + return typeXml; + } + + + public String getVersionUuId() { + return versionUuId; + } + + public void setVersionUuId(String uuId) { + versionUuId = uuId; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseKeyType.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseKeyType.java new file mode 100644 index 0000000000..3ba913de31 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseKeyType.java @@ -0,0 +1,27 @@ +/*- + * ============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.dao.types; + +public enum LicenseKeyType { + Universal, + Unique, + One_Time +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseTerm.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseTerm.java new file mode 100644 index 0000000000..729a985473 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseTerm.java @@ -0,0 +1,28 @@ +/*- + * ============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.dao.types; + +public enum LicenseTerm { + Fixed_Term, + Perpetual, + Unlimited, + Other +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/MultiChoiceOrOther.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/MultiChoiceOrOther.java new file mode 100644 index 0000000000..df9d6887ce --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/MultiChoiceOrOther.java @@ -0,0 +1,172 @@ +/*- + * ============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.dao.types; + +import com.datastax.driver.mapping.annotations.Transient; +import com.datastax.driver.mapping.annotations.UDT; +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.common.errors.ErrorCategory; +import org.openecomp.sdc.common.errors.ErrorCode; + +import java.util.HashSet; +import java.util.Set; + +@UDT(keyspace = "dox", name = "multi_choice_or_other") +public class MultiChoiceOrOther<E extends Enum<E>> { + public static final String MULTI_CHOICE_OR_OTHER_INVALID_ENUM_ERR_ID = + "MULTI_CHOICE_OR_OTHER_INVALID_ENUM_ERR_ID"; + public static final String MULTI_CHOICE_OR_OTHER_INVALID_ENUM_MSG = + "Enum used as part of MultiChoiceOrOther type must contain the value 'Other'"; + public static final String OTHER_ENUM_VALUE = "Other"; + + @Transient + private Set<E> choices; + @Transient + private String other; + + + private Set<String> results; + + public MultiChoiceOrOther() { + } + + /** + * Instantiates a new Multi choice or other. + * + * @param choices the choices + * @param other the other + */ + public MultiChoiceOrOther(Set<E> choices, String other) { + this.choices = choices; + this.other = other; + results = resolveResult(); + } + + public Set<E> getChoices() { + return choices; + } + + public void setChoices(Set<E> choices) { + this.choices = choices; + } + + public String getOther() { + return other; + } + + public void setOther(String other) { + this.other = other; + } + + public Set<String> getResults() { + return results; + } + + /** + * Sets results. + * + * @param results the results + */ + public void setResults(Set<String> results) { + if (choices != null) { + if (results == null) { + this.results = resolveResult(); + } + } else { + this.results = results; + } + } + + private Set<String> resolveResult() { + results = new HashSet<>(); + if (choices.size() == 1 && OTHER_ENUM_VALUE.equals(choices.iterator().next().name())) { + results.add(other); + } else { + for (E choice : choices) { + results.add(choice.name()); + } + } + + return results; + } + + /** + * Resolve enum. + * + * @param enumClass the enum class + */ + public void resolveEnum(Class<E> enumClass) { + if (choices != null || results == null || results.size() == 0) { + return; + } + + choices = new HashSet<>(); + if (results.size() > 1) { + for (String result : results) { + choices.add(E.valueOf(enumClass, result)); + } + } else { + String result = results.iterator().next(); + try { + choices.add(E.valueOf(enumClass, result)); + } catch (IllegalArgumentException illegalArgumentException) { + try { + choices.add(E.valueOf(enumClass, OTHER_ENUM_VALUE)); + } catch (IllegalArgumentException ex) { + throw new CoreException(new ErrorCode.ErrorCodeBuilder() + .withId(MULTI_CHOICE_OR_OTHER_INVALID_ENUM_ERR_ID) + .withMessage(MULTI_CHOICE_OR_OTHER_INVALID_ENUM_MSG) + .withCategory(ErrorCategory.APPLICATION).build()); + } + other = result; + } + } + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + + MultiChoiceOrOther<?> that = (MultiChoiceOrOther<?>) obj; + + if (choices != null ? !choices.equals(that.choices) : that.choices != null) { + return false; + } + if (other != null ? !other.equals(that.other) : that.other != null) { + return false; + } + return results != null ? results.equals(that.results) : that.results == null; + + } + + @Override + public int hashCode() { + int result = choices != null ? choices.hashCode() : 0; + result = 31 * result + (other != null ? other.hashCode() : 0); + result = 31 * result + (results != null ? results.hashCode() : 0); + return result; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/OperationalScope.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/OperationalScope.java new file mode 100644 index 0000000000..ed9497d30b --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/OperationalScope.java @@ -0,0 +1,32 @@ +/*- + * ============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.dao.types; + +public enum OperationalScope { + Network_Wide, + Availability_Zone, + Data_Center, + Tenant, + VM, + CPU, + Core, + Other +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/ThresholdUnit.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/ThresholdUnit.java new file mode 100644 index 0000000000..bd0fa41073 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/ThresholdUnit.java @@ -0,0 +1,26 @@ +/*- + * ============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.dao.types; + +public enum ThresholdUnit { + Absolute, + Percentage +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/VendorLicenseModelEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/VendorLicenseModelEntity.java new file mode 100644 index 0000000000..ea93b1ab4f --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/VendorLicenseModelEntity.java @@ -0,0 +1,153 @@ +/*- + * ============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.dao.types; + +import com.datastax.driver.mapping.annotations.Column; +import com.datastax.driver.mapping.annotations.Computed; +import com.datastax.driver.mapping.annotations.Frozen; +import com.datastax.driver.mapping.annotations.PartitionKey; +import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.dao.types.VersionableEntity; + +import java.util.Objects; + +@Table(keyspace = "dox", name = "vendor_license_model") +public class VendorLicenseModelEntity implements VersionableEntity { + public static final String ENTITY_TYPE = "Vendor License Model"; + + @PartitionKey + @Column(name = "vlm_id") + private String id; + + @PartitionKey(value = 1) + @Frozen + private Version version; + + // @Column(name = "last_modification_time") + // private Date lastModificationTime; + + @Column(name = "vendor_name") + private String vendorName; + private String description; + @Column(name = "icon") + private String iconRef; + + @Computed("writetime(vendor_name)") + private Long writetimeMicroSeconds; + + public VendorLicenseModelEntity() { + } + + public VendorLicenseModelEntity(String id, Version version) { + this.id = id; + this.version = version; + } + + @Override + public String getEntityType() { + return ENTITY_TYPE; + } + + @Override + public String getFirstClassCitizenId() { + return getId(); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Override + public Version getVersion() { + return version; + } + + @Override + public void setVersion(Version version) { + this.version = version; + } + + public String getVendorName() { + return vendorName; + } + + public void setVendorName(String vendorName) { + this.vendorName = vendorName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getIconRef() { + return iconRef; + } + + public void setIconRef(String iconRef) { + this.iconRef = iconRef; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + VendorLicenseModelEntity that = (VendorLicenseModelEntity) obj; + return Objects.equals(id, that.id) + && Objects.equals(version, that.version) + && Objects.equals(vendorName, that.vendorName) + && Objects.equals(description, that.description) + && Objects.equals(iconRef, that.iconRef); + } + + @Override + public int hashCode() { + return Objects.hash(id, version, vendorName, description, iconRef); + } + + // public Date getLastModificationTime() { + // return lastModificationTime; + // } + // + // public void setLastModificationTime(Date lastModificationTime) { + // this.lastModificationTime = lastModificationTime; + // } + + public Long getWritetimeMicroSeconds() { + return writetimeMicroSeconds; + } + + public void setWritetimeMicroSeconds(Long writetimeMicroSeconds) { + this.writetimeMicroSeconds = writetimeMicroSeconds; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/xml/AggregationFunctionForXml.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/xml/AggregationFunctionForXml.java new file mode 100644 index 0000000000..e2a6be6b9e --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/xml/AggregationFunctionForXml.java @@ -0,0 +1,33 @@ +/*- + * ============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.dao.types.xml; + +public class AggregationFunctionForXml { + private String value; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/xml/EntitlementMetricForXml.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/xml/EntitlementMetricForXml.java new file mode 100644 index 0000000000..8a449446ec --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/xml/EntitlementMetricForXml.java @@ -0,0 +1,33 @@ +/*- + * ============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.dao.types.xml; + +public class EntitlementMetricForXml { + private String value; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/xml/EntitlementTimeForXml.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/xml/EntitlementTimeForXml.java new file mode 100644 index 0000000000..c78a2d6d91 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/xml/EntitlementTimeForXml.java @@ -0,0 +1,33 @@ +/*- + * ============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.dao.types.xml; + +public class EntitlementTimeForXml { + private String value; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/xml/LicenseKeyTypeForXml.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/xml/LicenseKeyTypeForXml.java new file mode 100644 index 0000000000..c8c0d3067e --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/xml/LicenseKeyTypeForXml.java @@ -0,0 +1,33 @@ +/*- + * ============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.dao.types.xml; + +public class LicenseKeyTypeForXml { + private String value; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/xml/ThresholdForXml.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/xml/ThresholdForXml.java new file mode 100644 index 0000000000..11627160ad --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/xml/ThresholdForXml.java @@ -0,0 +1,42 @@ +/*- + * ============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.dao.types.xml; + +public class ThresholdForXml { + String unit; + int value; + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/JsonErrorBuilder.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/JsonErrorBuilder.java new file mode 100644 index 0000000000..a11092bbe3 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/JsonErrorBuilder.java @@ -0,0 +1,51 @@ +/*- + * ============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.errors; + +import org.openecomp.sdc.common.errors.ErrorCategory; +import org.openecomp.sdc.common.errors.ErrorCode; + +public class JsonErrorBuilder { + + private static final String JSON_ERROR_OCCURED_DURING_ARTIFACT_GENERATION_ERR_ID = + "JSON_ERROR_OCCURED_DURING_ARTIFACT_GENERATION_ERR_ID"; + private static final String JSON_ERROR_OCCURED_DURING_ARTIFACT_GENERATION_ERR_ID_MSG = + "Json error occured during artifact generation:%s."; + + private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder(); + + /** + * Instantiates a new Json error builder. + * + * @param exceptionMessage the exception message + */ + public JsonErrorBuilder(String exceptionMessage) { + builder.withId(JSON_ERROR_OCCURED_DURING_ARTIFACT_GENERATION_ERR_ID); + builder.withCategory(ErrorCategory.APPLICATION); + builder.withMessage( + String.format(JSON_ERROR_OCCURED_DURING_ARTIFACT_GENERATION_ERR_ID_MSG, exceptionMessage)); + } + + public ErrorCode build() { + return builder.build(); + } + +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/LicensingDataInvalidErrorBuilder.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/LicensingDataInvalidErrorBuilder.java new file mode 100644 index 0000000000..dfc9a93751 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/LicensingDataInvalidErrorBuilder.java @@ -0,0 +1,49 @@ +/*- + * ============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.errors; + +import org.openecomp.core.utilities.CommonMethods; +import org.openecomp.sdc.common.errors.ErrorCategory; +import org.openecomp.sdc.common.errors.ErrorCode; + +import java.util.List; + +public class LicensingDataInvalidErrorBuilder { + private static final String LICENSING_DATA_INVALID_MSG = "Invalid licensing data: %s"; + private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder(); + + /** + * Instantiates a new Licensing data invalid error builder. + * + * @param licensingDataErrors the licensing data errors + */ + public LicensingDataInvalidErrorBuilder(List<String> licensingDataErrors) { + builder.withId(VendorLicenseErrorCodes.LICENSING_DATA_INVALID); + builder.withCategory(ErrorCategory.APPLICATION); + builder.withMessage(String.format(LICENSING_DATA_INVALID_MSG, + CommonMethods.listToSeparatedString(licensingDataErrors, ','))); + } + + public ErrorCode build() { + return builder.build(); + } + +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/SubmitUncompletedLicenseModelErrorBuilder.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/SubmitUncompletedLicenseModelErrorBuilder.java new file mode 100644 index 0000000000..0a00cff8ea --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/SubmitUncompletedLicenseModelErrorBuilder.java @@ -0,0 +1,50 @@ +/*- + * ============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.errors; + +import org.openecomp.sdc.common.errors.ErrorCategory; +import org.openecomp.sdc.common.errors.ErrorCode; + +public class SubmitUncompletedLicenseModelErrorBuilder { + + private static final String SUBMIT_UNCOMPLETED_LICENSE_MODEL_MSG = + "Uncompleted vendor license model %s cannot be submitted. " + + "It must contain license_agreement(s) that all feature groups " + + "contain at least one entitlement pool."; + private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder(); + + /** + * Instantiates a new Submit uncompleted license model error builder. + * + * @param vlmId the vlm id + */ + public SubmitUncompletedLicenseModelErrorBuilder(String vlmId) { + builder.withId(VendorLicenseErrorCodes.SUBMIT_UNCOMPLETED_LICENSE_MODEL); + builder.withCategory(ErrorCategory.APPLICATION); + builder.withMessage(String.format(SUBMIT_UNCOMPLETED_LICENSE_MODEL_MSG, vlmId)); + } + + public ErrorCode build() { + return builder.build(); + } + + +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/VendorLicenseErrorCodes.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/VendorLicenseErrorCodes.java new file mode 100644 index 0000000000..4cd7a5bc1b --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/VendorLicenseErrorCodes.java @@ -0,0 +1,28 @@ +/*- + * ============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.errors; + +public class VendorLicenseErrorCodes { + + public static final String VENDOR_LICENSE_MODEL_NOT_FOUND = "VENDOR_LICENSE_MODEL_NOT_FOUND"; + public static final String SUBMIT_UNCOMPLETED_LICENSE_MODEL = "SUBMIT_UNCOMPLETED_LICENSE_MODEL"; + public static final String LICENSING_DATA_INVALID = "LICENSING_DATA_INVALID"; +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/VendorLicenseModelNotFoundErrorBuilder.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/VendorLicenseModelNotFoundErrorBuilder.java new file mode 100644 index 0000000000..d2dc1d6f00 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/VendorLicenseModelNotFoundErrorBuilder.java @@ -0,0 +1,48 @@ +/*- + * ============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.errors; + +import org.openecomp.sdc.common.errors.ErrorCategory; +import org.openecomp.sdc.common.errors.ErrorCode; + +public class VendorLicenseModelNotFoundErrorBuilder { + + private static final String VENDOR_LICENSE_MODEL_NOT_FOUND_MSG = + "Vendor license model with id %s not found."; + private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder(); + + /** + * Instantiates a new Vendor license model not found error builder. + * + * @param vendorLicenseModelId the vendor license model id + */ + public VendorLicenseModelNotFoundErrorBuilder(String vendorLicenseModelId) { + builder.withId(VendorLicenseErrorCodes.VENDOR_LICENSE_MODEL_NOT_FOUND); + builder.withCategory(ErrorCategory.APPLICATION); + builder.withMessage(String.format(VENDOR_LICENSE_MODEL_NOT_FOUND_MSG, vendorLicenseModelId)); + } + + public ErrorCode build() { + return builder.build(); + } + + +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/facade/VendorLicenseFacade.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/facade/VendorLicenseFacade.java new file mode 100644 index 0000000000..e36852d25f --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/facade/VendorLicenseFacade.java @@ -0,0 +1,89 @@ +/*- + * ============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.facade; + +import org.openecomp.sdc.common.errors.ErrorCode; +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.LicenseAgreementEntity; +import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementModel; +import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; +import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity; +import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.types.VersionInfo; +import org.openecomp.sdc.versioning.types.VersionableEntityAction; + +import java.util.Collection; + +public interface VendorLicenseFacade { + + void checkin(String vendorLicenseModelId, String user); + + void submit(String vendorLicenseModelId, String user); + + FeatureGroupEntity getFeatureGroup(FeatureGroupEntity featureGroup, String user); + + FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup, String user); + + LicenseAgreementEntity getLicenseAgreement(String vlmId, Version version, + String licenseAgreementId, String user); + + LicenseAgreementModel getLicenseAgreementModel(String vlmId, Version version, + String licenseAgreementId, String user); + + EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool, String user); + + LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user); + + void updateEntitlementPool(EntitlementPoolEntity entitlementPool, String user); + + Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version, + String user); + + Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version, + String user); + + void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user); + + + VersionedVendorLicenseModel getVendorLicenseModel(String vlmId, Version version, String user); + + VendorLicenseModelEntity createVendorLicenseModel( + VendorLicenseModelEntity vendorLicenseModelEntity, String user); + + + LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement, + String user); + + FeatureGroupEntity createFeatureGroup(FeatureGroupEntity featureGroup, String user); + + + Collection<ErrorCode> validateLicensingData(String vlmId, Version vlmVersion, + String licenseAgreementId, + Collection<String> featureGroupIds); + + VersionInfo getVersionInfo(String vendorLicenseModelId, VersionableEntityAction action, + String user); + + void updateVlmLastModificationTime(String vendorLicenseModelId, Version version); +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/facade/VendorLicenseFacadeFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/facade/VendorLicenseFacadeFactory.java new file mode 100644 index 0000000000..540cc5ba66 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/facade/VendorLicenseFacadeFactory.java @@ -0,0 +1,32 @@ +/*- + * ============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.facade; + +import org.openecomp.core.factory.api.AbstractComponentFactory; +import org.openecomp.core.factory.api.AbstractFactory; + +public abstract class VendorLicenseFacadeFactory + extends AbstractComponentFactory<VendorLicenseFacade> { + + public static VendorLicenseFacadeFactory getInstance() { + return AbstractFactory.getInstance(VendorLicenseFacadeFactory.class); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/healing/HealingService.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/healing/HealingService.java new file mode 100644 index 0000000000..027cb1e5be --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/healing/HealingService.java @@ -0,0 +1,31 @@ +/*- + * ============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.healing; + +import org.openecomp.sdc.versioning.dao.types.VersionableEntity; + +public interface HealingService { + + // VersionableEntity heal(VersionableEntity toHeal, String user); + VersionableEntity heal(VersionableEntity toHeal, String user); +} + + diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/VendorLicenseArtifactsService.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/VendorLicenseArtifactsService.java new file mode 100644 index 0000000000..c0610a99cd --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/VendorLicenseArtifactsService.java @@ -0,0 +1,32 @@ +/*- + * ============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; + +import org.openecomp.core.utilities.file.FileContentHandler; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.util.List; + +public interface VendorLicenseArtifactsService { + + FileContentHandler createLicenseArtifacts(String vspId, String vlmId, Version vlmVersion, + List<String> featureGroups, String user); +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/types/VersionedVendorLicenseModel.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/types/VersionedVendorLicenseModel.java new file mode 100644 index 0000000000..deb321f14e --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/types/VersionedVendorLicenseModel.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.types; + +import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity; +import org.openecomp.sdc.versioning.types.VersionInfo; + +public class VersionedVendorLicenseModel { + private VendorLicenseModelEntity vendorLicenseModel; + private VersionInfo versionInfo; + + public VersionedVendorLicenseModel() { + } + + public VersionedVendorLicenseModel(VendorLicenseModelEntity vendorLicenseModel, + VersionInfo versionInfo) { + this.vendorLicenseModel = vendorLicenseModel; + this.versionInfo = versionInfo; + } + + public VendorLicenseModelEntity getVendorLicenseModel() { + return vendorLicenseModel; + } + + public void setVendorLicenseModel(VendorLicenseModelEntity vendorLicenseModel) { + this.vendorLicenseModel = vendorLicenseModel; + } + + public VersionInfo getVersionInfo() { + return versionInfo; + } + + public void setVersionInfo(VersionInfo versionInfo) { + this.versionInfo = versionInfo; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/resources/factoryConfiguration.json new file mode 100644 index 0000000000..7f59b42103 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/resources/factoryConfiguration.json @@ -0,0 +1,11 @@ +{ + "org.openecomp.sdc.vendorlicense.VendorLicenseArtifactServiceFactory": "org.openecomp.sdc.vendorlicense.VendorLicenseArtifactServiceFactoryImpl", + "org.openecomp.sdc.vendorlicense.HealingServiceFactory": "org.openecomp.sdc.vendorlicense.SimpleHealingServiceServiceFactoryImpl", + "org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory": "org.openecomp.sdc.vendorlicense.facade.impl.VendorLicenseFacadeFactoryImpl", + "org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDaoFactory": "org.openecomp.sdc.vendorlicense.dao.impl.VendorLicenseModelDaoFactoryImpl", + "org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDaoFactory": "org.openecomp.sdc.vendorlicense.dao.impl.LicenseAgreementDaoFactoryImpl", + "org.openecomp.sdc.vendorlicense.dao.FeatureGroupDaoFactory": "org.openecomp.sdc.vendorlicense.dao.impl.FeatureGroupDaoFactoryImpl", + "org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDaoFactory": "org.openecomp.sdc.vendorlicense.dao.impl.LicenseKeyGroupDaoFactoryImpl", + "org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDaoFactory": "org.openecomp.sdc.vendorlicense.dao.impl.EntitlementPoolDaoFactoryImpl" + +}
\ No newline at end of file |