-
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 #1185 from PublicisSapient/DTS-38319
DTS-38319 | Release <10.1.0>
- Loading branch information
Showing
3 changed files
with
140 additions
and
1 deletion.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
...issapient/kpidashboard/apis/mongock/rollback/release_1010/UpdateFieldMappingSructure.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,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; | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
...cissapient/kpidashboard/apis/mongock/upgrade/release_1010/UpdateFieldMappingSructure.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.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; | ||
} | ||
} |
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