public void update(StreetAddress address) { try { HashMap addressHashMap = address.toHashMap(); //Calendar calendar=Calendar.getInstance(); //String time = new String(new Long(calendar.getTimeInMillis()).toString()); HashMap whereKeyValuePairs = new HashMap(); whereKeyValuePairs.put(StreetAddressData.ID,address.getId()); whereKeyValuePairs.put(UserData.USERNAME,this.userName); super.updateWhere(whereKeyValuePairs, addressHashMap); this.setDefault(address.getId()); if(abcs.logic.communication.log.config.type.LogConfigTypes.LOGGING.contains(abcs.logic.communication.log.config.type.LogConfigType.SQLLOGGING)) { LogUtil.put(LogFactory.getInstance("Command Success",this,"update")); } } catch(Exception e) { if(abcs.logic.communication.log.config.type.LogConfigTypes.LOGGING.contains(abcs.logic.communication.log.config.type.LogConfigType.SQLLOGGING)) { LogUtil.put(LogFactory.getInstance("Command Failed",this,"add",e)); } } }
public void setDefault(String value) { try { HashMap updateKeyAndValue = new HashMap(); HashMap whereKeyAndValue = new HashMap(); whereKeyAndValue.put(UserData.USERNAME,userName); //remove old default value if it exist StreetAddress streetAddress = getDefault(); if(streetAddress!=null) { updateKeyAndValue.put(StreetAddressData.DEFAULT, StringUtil.getInstance().EMPTY_STRING); whereKeyAndValue.put(StreetAddressData.ID,streetAddress.getId()); super.updateWhere(whereKeyAndValue,updateKeyAndValue); } //now update new default whereKeyAndValue.put(StreetAddressData.ID,value); updateKeyAndValue.put(StreetAddressData.DEFAULT,StreetAddressData.DEFAULT); super.updateWhere(whereKeyAndValue,updateKeyAndValue); if(abcs.logic.communication.log.config.type.LogConfigTypes.LOGGING.contains(abcs.logic.communication.log.config.type.LogConfigType.SQLLOGGING)) { LogUtil.put(LogFactory.getInstance("Command Success",this,"setDefault")); } } catch(Exception e) { if(abcs.logic.communication.log.config.type.LogConfigTypes.LOGGING.contains(abcs.logic.communication.log.config.type.LogConfigType.SQLLOGGING)) { LogUtil.put(LogFactory.getInstance("Command Failed",this,"setShippingAddress",e)); } } }
private void add(StreetAddress address,String index) { try { Vector values = new Vector(); values.add(index); values.add(userName); values.add(StringUtil.getInstance().EMPTY_STRING); values.add(address.getName()); values.add(address.getStreet()); values.add(address.getCity()); values.add(address.getState()); values.add(address.getCode()); values.add(address.getCountry()); Calendar calendar=Calendar.getInstance(); String time = new String(new Long(calendar.getTimeInMillis()).toString()); values.add(time); super.insert(values); this.setDefault(getLastId()); if(abcs.logic.communication.log.config.type.LogConfigTypes.LOGGING.contains(abcs.logic.communication.log.config.type.LogConfigType.SQLLOGGING)) { LogUtil.put(LogFactory.getInstance("Command Success",this,"add")); } } catch(Exception e) { if(abcs.logic.communication.log.config.type.LogConfigTypes.LOGGING.contains(abcs.logic.communication.log.config.type.LogConfigType.SQLLOGGING)) { LogUtil.put(LogFactory.getInstance("Command Failed",this,"add",e)); } } }