Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DTS-38044 build kpi align| Release <10.1.0> #1164

Merged
merged 3 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright 2014 CapitalOne, LLC.
* Further development Copyright 2022 Sapient Corporation.
*
* 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.
*/

package com.publicissapient.kpidashboard.apis.mongock.rollback.release_940;

import org.bson.Document;
import org.springframework.data.mongodb.core.MongoTemplate;

import com.mongodb.client.MongoCollection;

import io.mongock.api.annotations.ChangeUnit;
import io.mongock.api.annotations.Execution;
import io.mongock.api.annotations.RollbackExecution;

/**
* @author shunaray
*/
@ChangeUnit(id = "build_kpi_align", order = "", author = "shunaray", systemVersion = "")
public class BuildKpiOrder {
private final MongoTemplate mongoTemplate;

public BuildKpiOrder(MongoTemplate mongoTemplate) {
this.mongoTemplate = mongoTemplate;
}

@Execution
public boolean execution() {
MongoCollection<Document> kpiCategoryMapping = mongoTemplate.getCollection("kpi_category_mapping");

// Update documents
updateDocument(kpiCategoryMapping, "kpi164", 9);//scope churn kpi
updateDocument(kpiCategoryMapping, "kpi8", 8);//code build time kpi
return true;
}

private void updateDocument(MongoCollection<Document> kpiCategoryMapping, String kpiId, int kpiOrder) {
// Create the filter
Document filter = new Document("kpiId", kpiId);

// Create the update
Document update = new Document("$set", new Document("kpiOrder", kpiOrder));

// Perform the update
kpiCategoryMapping.updateOne(filter, update);
}

@RollbackExecution
public void rollbackOrdering() {
MongoCollection<Document> kpiCategoryMapping = mongoTemplate.getCollection("kpi_category_mapping");

// Update documents
updateDocument(kpiCategoryMapping, "kpi164", 8);//scope churn kpi
updateDocument(kpiCategoryMapping, "kpi8", 9);//code build time kpi
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright 2014 CapitalOne, LLC.
* Further development Copyright 2022 Sapient Corporation.
*
* 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.
*/

package com.publicissapient.kpidashboard.apis.mongock.upgrade.release_940;

import org.bson.Document;
import org.springframework.data.mongodb.core.MongoTemplate;

import com.mongodb.client.MongoCollection;

import io.mongock.api.annotations.ChangeUnit;
import io.mongock.api.annotations.Execution;
import io.mongock.api.annotations.RollbackExecution;

/**
* @author shunaray
*/
@ChangeUnit(id = "build_kpi_align", order = "", author = "shunaray", systemVersion = "")
public class BuildKpiOrder {
private final MongoTemplate mongoTemplate;

public BuildKpiOrder(MongoTemplate mongoTemplate) {
this.mongoTemplate = mongoTemplate;
}

@Execution
public boolean execution() {
MongoCollection<Document> kpiCategoryMapping = mongoTemplate.getCollection("kpi_category_mapping");

// Update documents
updateDocument(kpiCategoryMapping, "kpi164", 8);//scope churn kpi
updateDocument(kpiCategoryMapping, "kpi8", 9);//code build time kpi
return true;
}

private void updateDocument(MongoCollection<Document> kpiCategoryMapping, String kpiId, int kpiOrder) {
// Create the filter
Document filter = new Document("kpiId", kpiId);

// Create the update
Document update = new Document("$set", new Document("kpiOrder", kpiOrder));

// Perform the update
kpiCategoryMapping.updateOne(filter, update);
}

@RollbackExecution
public void rollbackOrdering() {
MongoCollection<Document> kpiCategoryMapping = mongoTemplate.getCollection("kpi_category_mapping");

// Update documents
updateDocument(kpiCategoryMapping, "kpi164", 9);//scope churn kpi
updateDocument(kpiCategoryMapping, "kpi8", 8);//code build time kpi
}
}
Loading