Пример #1
0
  /** @return XML representation of cart contents */
  public String toXml() {
    StringBuffer xml = new StringBuffer();
    xml.append("<?xml version=\"1.0\"?>\n");
    // Append the current system time to check for latest async calls
    xml.append(
        "<cart generated=\""
            + System.currentTimeMillis()
            + "\" total=\""
            + getCartTotal()
            + "\">\n");
    // Generate xml tags and values by iterating through the contents
    for (Iterator<Item> I = contents.values().iterator(); I.hasNext(); ) {
      Item item = I.next();
      // int itemQuantity = contents.get(item).intValue();

      xml.append("<item code=\"" + item.getCode() + "\">\n");
      xml.append("<name>");
      xml.append(item.getName());
      xml.append("</name>\n");
      // xml.append("<quantity>");
      // xml.append(itemQuantity);
      // xml.append("</quantity>\n");
      xml.append("</item>\n");
    }
    // xml.append("<feed>").append(cartXml).append("</feed>\n");
    xml.append("</cart>\n");
    return xml.toString();
  }
Пример #2
0
    @Override
    protected TreeMap<Float, DropsiteLocation> doInBackground(
        android.location.Location... location) {

      TreeMap<Float, DropsiteLocation> locations = new TreeMap<Float, DropsiteLocation>();

      try {

        if (location[0] != null) {
          android.location.Location currentLocation = location[0];

          SelectResult result =
              SimpleDB.getInstance()
                  .select(new SelectRequest("select * from `Dropsites` limit 25"));
          for (Item dropsite : result.getItems()) {
            android.location.Location dropsiteLocation =
                new android.location.Location(currentLocation.getProvider());

            DropsiteLocation internalDropsiteLocation = new DropsiteLocation();
            internalDropsiteLocation.setId(dropsite.getName());

            // used to temporarily store hours of open and close for each location
            Hashtable<Integer, String> dateOpen = new Hashtable<Integer, String>();
            Hashtable<Integer, String> dateClose = new Hashtable<Integer, String>();

            for (Attribute attribute : dropsite.getAttributes()) {

              if (attribute.getName().equalsIgnoreCase("location"))
                internalDropsiteLocation.setLocation(attribute.getValue());
              if (attribute.getName().equalsIgnoreCase("description"))
                internalDropsiteLocation.setDescription(attribute.getValue());

              if (attribute.getName().equalsIgnoreCase("start_collection"))
                internalDropsiteLocation.setDateOpen(DateTime.parse(attribute.getValue()));
              if (attribute.getName().equalsIgnoreCase("end_collection"))
                internalDropsiteLocation.setDateClose(DateTime.parse(attribute.getValue()));

              if (attribute.getName().equalsIgnoreCase("lat"))
                dropsiteLocation.setLatitude(Double.parseDouble(attribute.getValue()));
              if (attribute.getName().equalsIgnoreCase("lng"))
                dropsiteLocation.setLongitude(Double.parseDouble(attribute.getValue()));

              if (attribute.getName().equalsIgnoreCase("city"))
                internalDropsiteLocation.setCityCode(attribute.getValue());
            }

            // store the location of the lot
            internalDropsiteLocation.setPoint(
                new LatLng(dropsiteLocation.getLatitude(), dropsiteLocation.getLongitude()));

            // save it to our locations listing to return back to the consumer
            locations.put(currentLocation.distanceTo(dropsiteLocation), internalDropsiteLocation);
          }
        }
      } catch (Exception e) {
        Log.e("GetDropsitesTask", "Failure attempting to get locations", e);
      }

      return locations;
    }
Пример #3
0
 public Item itemWithName(String name) {
   name = name.toLowerCase();
   for (Item it : itemList) {
     if (it.getName().toLowerCase().equals(name)) {
       return it;
     }
   }
   return null;
 }
  @Override
  public String getItemTitle(BasicWorkflowItem wi) throws SQLException {
    Item myitem = wi.getItem();
    String title = myitem.getName();

    // only return the first element, or "Untitled"
    if (StringUtils.isNotBlank(title)) {
      return title;
    } else {
      return I18nUtil.getMessage("org.dspace.workflow.WorkflowManager.untitled ");
    }
  }
Пример #5
0
 // 读写的方法
 public void Save() {
   try {
     file.delete();
     FileWriter writer = new FileWriter(file);
     for (Item i : list)
       writer.write(
           i.getNumber()
               + ";"
               + i.getCategory()
               + ";"
               + i.getName()
               + ";"
               + i.getModel()
               + ";"
               + i.getStock()
               + "\n");
     writer.close();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Пример #6
0
 public void show() {
   Collections.sort(
       list,
       new Comparator<Item>() {
         public int compare(Item i1, Item i2) {
           if (i1.getNumber() > i2.getNumber()) return 1;
           else return -1;
         }
       });
   for (Item i : list)
     System.out.println(
         i.getNumber()
             + ";"
             + i.getCategory()
             + ";"
             + i.getName()
             + ";"
             + i.getModel()
             + ";"
             + i.getStock());
 }
  /** notify the submitter that the item is archived */
  protected void notifyOfArchive(Context context, Item item, Collection coll)
      throws SQLException, IOException {
    try {
      // Get submitter
      EPerson ep = item.getSubmitter();
      // Get the Locale
      Locale supportedLocale = I18nUtil.getEPersonLocale(ep);
      Email email = Email.getEmail(I18nUtil.getEmailFilename(supportedLocale, "submit_archive"));

      // Get the item handle to email to user
      String handle = handleService.findHandle(context, item);

      // Get title
      String title = item.getName();
      if (StringUtils.isBlank(title)) {
        try {
          title = I18nUtil.getMessage("org.dspace.workflow.WorkflowManager.untitled");
        } catch (MissingResourceException e) {
          title = "Untitled";
        }
      }

      email.addRecipient(ep.getEmail());
      email.addArgument(title);
      email.addArgument(coll.getName());
      email.addArgument(handleService.getCanonicalForm(handle));

      email.send();
    } catch (MessagingException e) {
      log.warn(
          LogManager.getHeader(
              context,
              "notifyOfArchive",
              "cannot email user; item_id=" + item.getID() + ":  " + e.getMessage()));
    }
  }
Пример #8
0
 /** @return JSON representation of cart contents */
 public String toJson() {
   StringBuffer json = new StringBuffer();
   // Append the current system time to check for latest async calls
   json.append("{\"cart generated\":" + System.currentTimeMillis() + ",");
   json.append("\"total\":\"" + getCartTotal() + "\",");
   // Generate json array of json objects by iterating through the contents
   json.append("\"items\":[");
   for (Iterator<Item> I = contents.values().iterator(); I.hasNext(); ) {
     Item item = I.next();
     // int itemQuantity = contents.get(item).intValue();
     json.append("{");
     json.append("\"item code\":\"" + item.getCode() + "\",");
     json.append("\"name\":\"");
     json.append(item.getName()).append("\"},");
     // json.append("\"quantity\":");
     // json.append(itemQuantity).append("},");
   }
   // Remove , if it exists at the end of json for correcting the syntax
   if (json.toString().endsWith(",")) {
     json.setLength(json.length() - 1);
   }
   json.append("]}");
   return json.toString();
 }
Пример #9
0
    @Override
    protected TreeMap<Float, LotLocation> doInBackground(android.location.Location... location) {

      TreeMap<Float, LotLocation> locations = new TreeMap<Float, LotLocation>();

      try {

        // null checking party ahead, majority stems form no connection, perhaps a connection
        // manager could centralize this
        if (location[0] != null) {
          android.location.Location currentLocation = location[0];

          AmazonSimpleDBClient instance = SimpleDB.getInstance();
          if (instance != null) {

            SelectResult result =
                instance.select(
                    new SelectRequest("select * from `Locations` where active = '1' limit 50"));
            if (result != null) {
              for (Item lot : result.getItems()) {
                android.location.Location lotLocation =
                    new android.location.Location(currentLocation.getProvider());

                LotLocation internalLotLocation = new LotLocation();
                internalLotLocation.setId(lot.getName());

                // used to temporarily store hours of open and close for each location
                Hashtable<Integer, String> hoursOpen = new Hashtable<Integer, String>();
                Hashtable<Integer, String> hoursClose = new Hashtable<Integer, String>();

                for (Attribute attribute : lot.getAttributes()) {

                  if (attribute.getName().equalsIgnoreCase("location"))
                    internalLotLocation.setLocation(attribute.getValue());
                  if (attribute.getName().equalsIgnoreCase("rating"))
                    internalLotLocation.setRating(Float.parseFloat(attribute.getValue()));
                  if (attribute.getName().equalsIgnoreCase("business"))
                    internalLotLocation.setBusiness(attribute.getValue());
                  if (attribute.getName().equalsIgnoreCase("description"))
                    internalLotLocation.setDescription(attribute.getValue());
                  if (attribute.getName().equalsIgnoreCase("amex"))
                    internalLotLocation.setAcceptsAmex(
                        com.experiment.trax.utils.Boolean.valueOf(attribute.getValue()));
                  if (attribute.getName().equalsIgnoreCase("visa"))
                    internalLotLocation.setAcceptsVisa(
                        com.experiment.trax.utils.Boolean.valueOf(attribute.getValue()));
                  if (attribute.getName().equalsIgnoreCase("mastercard"))
                    internalLotLocation.setAcceptsMastercard(
                        com.experiment.trax.utils.Boolean.valueOf(attribute.getValue()));
                  if (attribute.getName().equalsIgnoreCase("discover"))
                    internalLotLocation.setAcceptsDiscover(
                        com.experiment.trax.utils.Boolean.valueOf(attribute.getValue()));
                  if (attribute.getName().equalsIgnoreCase("phone"))
                    internalLotLocation.setPhone(attribute.getValue());
                  if (attribute.getName().equalsIgnoreCase("verified"))
                    internalLotLocation.setVerified(
                        com.experiment.trax.utils.Boolean.valueOf(attribute.getValue()));

                  // create a key -> value to day of week and time opened or closed
                  if (attribute.getName().equalsIgnoreCase("1_open"))
                    hoursOpen.put(1, attribute.getValue());
                  if (attribute.getName().equalsIgnoreCase("1_close"))
                    hoursClose.put(1, attribute.getValue());
                  if (attribute.getName().equalsIgnoreCase("2_open"))
                    hoursOpen.put(2, attribute.getValue());
                  if (attribute.getName().equalsIgnoreCase("2_close"))
                    hoursClose.put(2, attribute.getValue());
                  if (attribute.getName().equalsIgnoreCase("3_open"))
                    hoursOpen.put(3, attribute.getValue());
                  if (attribute.getName().equalsIgnoreCase("3_close"))
                    hoursClose.put(3, attribute.getValue());
                  if (attribute.getName().equalsIgnoreCase("4_open"))
                    hoursOpen.put(4, attribute.getValue());
                  if (attribute.getName().equalsIgnoreCase("4_close"))
                    hoursClose.put(4, attribute.getValue());
                  if (attribute.getName().equalsIgnoreCase("5_open"))
                    hoursOpen.put(5, attribute.getValue());
                  if (attribute.getName().equalsIgnoreCase("5_close"))
                    hoursClose.put(5, attribute.getValue());
                  if (attribute.getName().equalsIgnoreCase("6_open"))
                    hoursOpen.put(6, attribute.getValue());
                  if (attribute.getName().equalsIgnoreCase("6_close"))
                    hoursClose.put(6, attribute.getValue());
                  if (attribute.getName().equalsIgnoreCase("7_open"))
                    hoursOpen.put(7, attribute.getValue());
                  if (attribute.getName().equalsIgnoreCase("7_close"))
                    hoursClose.put(7, attribute.getValue());

                  if (attribute.getName().equalsIgnoreCase("lat"))
                    lotLocation.setLatitude(Double.parseDouble(attribute.getValue()));
                  if (attribute.getName().equalsIgnoreCase("lng"))
                    lotLocation.setLongitude(Double.parseDouble(attribute.getValue()));
                }

                // store the times the lot is opened and closed
                internalLotLocation.setHoursOpen(hoursOpen);
                internalLotLocation.setHoursClose(hoursClose);

                // store the location of the lot
                internalLotLocation.setPoint(
                    new LatLng(lotLocation.getLatitude(), lotLocation.getLongitude()));

                // save it to our locations listing to return back to the consumer
                locations.put(currentLocation.distanceTo(lotLocation), internalLotLocation);
              }
            }
          }
        }
      } catch (Exception e) {
        Log.e("GetLocationsTask", "Failure attempting to get locations", e);
      }

      return locations;
    }