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-38319 | Release <10.1.0> #1185

Merged
merged 3 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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,70 @@
/*
* 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.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;

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

/**
* @author girpatha
*/
@ChangeUnit(id = "r_update_fieldmapping_structure", order = "010102", author = "girpatha", systemVersion = "10.1.0")
public class UpdateFieldMappingSructure {

private final MongoTemplate mongoTemplate;
private static final String FIELD_NAME = "jiraTestAutomationIssueType";
private static final String FIELD_LABEL = "In Sprint Automation - Issue Types with Linked Test Case ";
public UpdateFieldMappingSructure(MongoTemplate mongoTemplate) {
this.mongoTemplate = mongoTemplate;
}

@Execution
public void execution() {

rollbackFieldLabel(FIELD_NAME);
}

@RollbackExecution
public void rollback() {

updateFieldLabel(FIELD_NAME, FIELD_LABEL);
}

private void rollbackFieldLabel(String fieldName) {
Update update = new Update();
update.unset("fieldLabel");
mongoTemplate.updateFirst(getQueryByFieldName(fieldName), update, "field_mapping_structure");
}

private void updateFieldLabel(String fieldName, String fieldLabel) {
Update update = new Update();
update.set("fieldLabel", fieldLabel);
mongoTemplate.updateFirst(getQueryByFieldName(fieldName), update, "field_mapping_structure");
}

private Query getQueryByFieldName(String fieldName) {
Query query = new Query();
query.addCriteria(Criteria.where("fieldName").is(fieldName));
return query;
}
}
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.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;

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

/**
* @author girpatha
*/
@ChangeUnit(id = "update_fieldmapping_structure", order = "10102", author = "girpatha", systemVersion = "10.1.0")
public class UpdateFieldMappingSructure {

private final MongoTemplate mongoTemplate;
private static final String FIELD_NAME = "jiraTestAutomationIssueType";
private static final String FIELD_LABEL = "In Sprint Automation - Issue Types with Linked Test Case ";

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

@Execution
public void execution() {
updateFieldLabel(FIELD_NAME, FIELD_LABEL);
}

@RollbackExecution
public void rollback() {
rollbackFieldLabel(FIELD_NAME);
}

private void updateFieldLabel(String fieldName, String fieldLabel) {
Update update = new Update();
update.set("fieldLabel", fieldLabel);
mongoTemplate.updateFirst(getQueryByFieldName(fieldName), update, "field_mapping_structure");
}

private void rollbackFieldLabel(String fieldName) {
Update update = new Update();
update.unset("fieldLabel");
mongoTemplate.updateFirst(getQueryByFieldName(fieldName), update, "field_mapping_structure");
}

private Query getQueryByFieldName(String fieldName) {
Query query = new Query();
query.addCriteria(Criteria.where("fieldName").is(fieldName));
return query;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1790,7 +1790,7 @@
},
{
"fieldName": "jiraTestAutomationIssueType",
"fieldLabel": "In Sprint Automation - Issue Types with Linked Defect ",
"fieldLabel": "In Sprint Automation - Issue Types with Linked Test Case ",
"fieldType": "chips",
"fieldCategory": "Issue_Type",
"section": "Issue Types Mapping",
Expand Down
Loading