Best Cerberus-source code snippet using org.cerberus.crud.entity.BuildRevisionParameters.getRevision
Source:BuildRevisionParametersService.java
...80 /**81 * Checking if the build Revision has already been deployed. If so the82 * Create cannot be performed83 */84 if (check_buildRevisionAlreadyUsed(brp.getApplication(), brp.getBuild(), brp.getRevision())) {85 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);86 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME)87 .replace("%OPERATION%", "Create")88 .replace("%REASON%", "Could not create this release as corresponding build " + brp.getBuild() + " revision " + brp.getRevision() + " has already been deployed in an environment."));89 ans.setResultMessage(msg);90 return ans;91 }92 return buildRevisionParametersDAO.create(brp);93 }94 @Override95 public Answer delete(BuildRevisionParameters brp) {96 Answer ans = new Answer();97 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);98 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));99 ans.setResultMessage(msg);100 /**101 * Checking if the build Revision has already been deployed. If so the102 * delete cannot be performed103 */104 if (check_buildRevisionAlreadyUsed(brp.getApplication(), brp.getBuild(), brp.getRevision())) {105 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);106 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME)107 .replace("%OPERATION%", "Delete")108 .replace("%REASON%", "Could not delete this release as corresponding build " + brp.getBuild() + " revision " + brp.getRevision() + " has already been deployed in an environment."));109 ans.setResultMessage(msg);110 return ans;111 }112 return buildRevisionParametersDAO.delete(brp);113 }114 @Override115 public Answer update(BuildRevisionParameters brp) {116 Answer ans = new Answer();117 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);118 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));119 ans.setResultMessage(msg);120 /**121 * Checking if the build Revision has already been deployed. If so the122 * update cannot be performed123 */124 if (check_buildRevisionAlreadyUsed(brp.getApplication(), brp.getBuild(), brp.getRevision())) {125 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);126 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME)127 .replace("%OPERATION%", "Update")128 .replace("%REASON%", "Could not update this release as corresponding build " + brp.getBuild() + " revision " + brp.getRevision() + " has already been deployed in an environment."));129 // "Could not update this release to this new build revision values as it has already been deployed in an environment."130 ans.setResultMessage(msg);131 return ans;132 }133 return buildRevisionParametersDAO.update(brp);134 }135 @Override136 public boolean check_buildRevisionAlreadyUsed(String application, String build, String revision) {137 try {138 // First set is to get the system value139 String system = "";140 system = applicationService.convert(applicationService.readByKey(application)).getSystem();141 // Then we check here inside countryenvparam_log table is the build revision has already been used.142 AnswerList resp = countryEnvParamLogService.readByVariousByCriteria(system, null, null, build, revision, 0, 0, "id", "asc", null, null);...
getRevision
Using AI Code Generation
1package org.cerberus.crud.entity;2import java.io.IOException;3import java.io.InputStream;4import java.util.Properties;5public class BuildRevisionParameters {6 private static final String VERSION_PROPERTIES_FILE = "/version.properties";7 private static final String REVISION_PROPERTY = "revision";8 private static final String BUILD_DATE_PROPERTY = "build.date";9 private static final String BUILD_TIME_PROPERTY = "build.time";10 private static String revision;11 private static String buildDate;12 private static String buildTime;13 public static String getRevision() {14 if (revision == null) {15 Properties versionProperties = new Properties();16 try {17 InputStream versionPropertiesStream = BuildRevisionParameters.class.getResourceAsStream(VERSION_PROPERTIES_FILE);18 if (versionPropertiesStream != null) {19 versionProperties.load(versionPropertiesStream);20 revision = versionProperties.getProperty(REVISION_PROPERTY);21 buildDate = versionProperties.getProperty(BUILD_DATE_PROPERTY);22 buildTime = versionProperties.getProperty(BUILD_TIME_PROPERTY);23 }24 } catch (IOException e) {25 revision = "Unable to read version.properties";26 }27 }28 return revision;29 }30 public static String getBuildDate() {31 getRevision();32 return buildDate;33 }34 public static String getBuildTime() {35 getRevision();36 return buildTime;37 }38}39package org.cerberus.crud.entity;40import org.cerberus.crud.entity.BuildRevisionParameters;41public class BuildRevisionParameters {42 private static final String VERSION_PROPERTIES_FILE = "/version.properties";43 private static final String REVISION_PROPERTY = "revision";44 private static final String BUILD_DATE_PROPERTY = "build.date";45 private static final String BUILD_TIME_PROPERTY = "build.time";46 private static String revision;47 private static String buildDate;48 private static String buildTime;49 public static String getRevision() {50 if (revision == null) {51 Properties versionProperties = new Properties();52 try {53 InputStream versionPropertiesStream = BuildRevisionParameters.class.getResourceAsStream(VERSION_PROPERTIES_FILE);54 if (versionPropertiesStream != null) {55 versionProperties.load(version
getRevision
Using AI Code Generation
1import org.cerberus.crud.entity.BuildRevisionParameters;2import org.cerberus.crud.factory.IFactoryBuildRevisionParameters;3import org.cerberus.crud.service.IBuildRevisionParametersService;4import org.cerberus.engine.entity.MessageEvent;5import org.cerberus.engine.entity.MessageGeneral;6import org.cerberus.exception.CerberusException;7import org.cerberus.util.answer.AnswerItem;8import org.springframework.beans.factory.annotation.Autowired;9import org.springframework.context.ApplicationContext;10import org.springframework.context.support.FileSystemXmlApplicationContext;11import org.springframework.stereotype.Controller;12import org.springframework.ui.Model;13import org.springframework.web.bind.annotation.RequestMapping;14import org.springframework.web.bind.annotation.RequestMethod;15import org.springframework.web.bind.annotation.RequestParam;16public class BuildRevisionController {17 private IBuildRevisionParametersService buildRevisionParametersService;18 private IFactoryBuildRevisionParameters factoryBuildRevisionParameters;19 @RequestMapping(value = "/BuildRevision", method = RequestMethod.GET)20 public String getBuildRevision(Model model) {21 return "BuildRevision";22 }23 @RequestMapping(value = "/BuildRevision", method = RequestMethod.POST)24 public String postBuildRevision(Model model, @RequestParam String revision, @RequestParam String build) {25 AnswerItem<BuildRevisionParameters> answer = new AnswerItem<>();26 MessageEvent message = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);27 MessageGeneral resultMessage = new MessageGeneral(MessageGeneralEnum.DATA_OPERATION_OK);28 try {29 BuildRevisionParameters buildRevisionParameters = factoryBuildRevisionParameters.create(revision, build);30 answer = buildRevisionParametersService.readByKey(revision, build);31 if (answer.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {32 buildRevisionParameters = answer.getItem();33 model.addAttribute("buildRevisionParameters", buildRevisionParameters);34 } else {35 model.addAttribute("buildRevisionParameters", null);36 }37 } catch (CerberusException ex) {38 message = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);39 message.setDescription(message.getDescription().replace("%DESCRIPTION%", ex.toString()));40 }41 model.addAttribute("message", message);
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!