Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class XmlBaseChild {
- protected Integer value;
- protected String text;
- @Autowired
- transient protected MasterCodeService masterCodeService;
- public XmlBaseChild(Integer value) {
- setValue(value);
- }
- /**
- * Set the Numeric value of the ChildView.
- * This code is common for all childViews and handles a null value.
- * @param value Numeric value of the ChildView
- */
- @JsonProperty(value="id")
- public void setValue(Integer value) {
- if (value == null) {
- this.value = null;
- this.text = null;
- return;
- }
- setConcreteValue(value);
- }
- /**
- * Set the Numeric value of the ChildView.
- * This code must be overridden by the concrete childViews.
- * @param value Numeric value of the ChildView
- */
- protected void setConcreteValue(Integer value){
- boolean keyNotFound = true;
- if (value != null && value > -1) {
- this.value = value;
- String messageKey = getValueFromMap(value, GetMasterCodeMapForChildView());
- if (messageKey != null) {
- this.text = LocalizeString(messageKey, null, getLocale);
- keyNotFound = false;
- }
- }
- if (keyNotFound){
- throw new NotFoundException();
- }
- }
- protected abstract Map<String, MasterCodeView> GetMasterCodeMapForChildView();
- }
- @Component
- @XmlRootElement(name=XmlDeployTool.VIEW_NAME)
- public class XmlDeployTool extends XmlBaseChild {
- public static Map<String, MasterCodeView> toolTypeCodes = new HashMap<String, MasterCodeView>();
- /**
- * Constructor for creating this object and preparing for marchalling (from java objects to xml/json).
- * @param value Numeric value of the ChildView
- * @param request HttpServletRequest
- * @param includeSelf Include SELF link
- * @param includeUP Include UP link
- */
- public XmlDeployTool(Integer value) {
- super(value);
- }
- /**
- * Initialize the Tool Type codes after the component is wired (postconstruct),
- * so that they are available in the constructor when an XmlDeploy object is created.
- */
- @PostConstruct
- protected void initializeDeployToolTypeCodes() {
- toolTypeCodes = convertListToMap(masterCodeService.getToolTypeCodes());
- }
- @Override
- protected Map<String, MasterCodeView> GetMasterCodeMapForChildView() {
- return toolTypeCodes;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement