-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1164 from PublicisSapient/DTS-38044-build-kpi-align
DTS-38044 build kpi align| Release <10.1.0>
- Loading branch information
Showing
2 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
...va/com/publicissapient/kpidashboard/apis/mongock/rollback/release_1010/BuildKpiOrder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_1010; | ||
|
||
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 = "r_build_kpi_align", order = "010101", author = "shunaray", systemVersion = "10.1.0") | ||
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 | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
...ava/com/publicissapient/kpidashboard/apis/mongock/upgrade/release_1010/BuildKpiOrder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_1010; | ||
|
||
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 = "10101", author = "shunaray", systemVersion = "10.1.0") | ||
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 | ||
} | ||
} |