コード例 #1
24
ファイル: Database.java プロジェクト: anchorwatt/baseball
 private void printResults(HashMap<Integer, Integer[]> gameNums, int year) {
   int totalNum = gameNums.get(year)[0] + gameNums.get(year)[1];
   String space = "";
   if (totalNum >= 1000) space = "";
   else if (totalNum < 1000) {
     space = " ";
   } else if (totalNum < 100) {
     space = "  ";
   } else if (totalNum < 10) {
     space = "   ";
   } else space = "    ";
   String postSpace = "";
   if (gameNums.get(year)[1] < 10) postSpace = " ";
   System.out.println(
       year
           + " season: "
           + space
           + totalNum
           + " total games logged "
           + space
           + "("
           + gameNums.get(year)[0]
           + " regular season; "
           + postSpace
           + gameNums.get(year)[1]
           + " postseason)");
 }
コード例 #2
19
ファイル: SVGUniverse.java プロジェクト: uazure/josm
  /**
   * Looks up a href within our universe. If the href refers to a document that is not loaded, it
   * will be loaded. The URL #target will then be checked against the SVG diagram's index and the
   * coresponding element returned. If there is no coresponding index, null is returned.
   */
  public SVGElement getElement(URI path, boolean loadIfAbsent) {
    try {
      // Strip fragment from URI
      URI xmlBase = new URI(path.getScheme(), path.getSchemeSpecificPart(), null);

      SVGDiagram dia = (SVGDiagram) loadedDocs.get(xmlBase);
      if (dia == null && loadIfAbsent) {
        // System.err.println("SVGUnivserse: " + xmlBase.toString());
        // javax.swing.JOptionPane.showMessageDialog(null, xmlBase.toString());
        URL url = xmlBase.toURL();

        loadSVG(url, false);
        dia = (SVGDiagram) loadedDocs.get(xmlBase);
        if (dia == null) {
          return null;
        }
      }

      String fragment = path.getFragment();
      return fragment == null ? dia.getRoot() : dia.getElement(fragment);
    } catch (Exception e) {
      Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, "Could not parse path " + path, e);
      return null;
    }
  }
コード例 #3
12
ファイル: Summary.java プロジェクト: HobbesFNM/openMAXIMS
  public String toXMLString(java.util.HashMap domMap) {
    StringBuffer sb = new StringBuffer();
    sb.append("<class type=\"" + this.getClass().getName() + "\" ");
    sb.append(" id=\"" + this.getId() + "\"");
    sb.append(
        " source=\"" + ims.configuration.EnvironmentConfig.getImportExportSourceName() + "\" ");
    sb.append(" classVersion=\"" + this.getClassVersion() + "\" ");
    sb.append(" component=\"" + this.getIsComponentClass() + "\" >");

    if (domMap.get(this) == null) {
      domMap.put(this, this);
      sb.append(this.fieldsToXMLString(domMap));
    }
    sb.append("</class>");

    String keyClassName = "Summary";
    String externalSource = ims.configuration.EnvironmentConfig.getImportExportSourceName();
    ims.configuration.ImportedObject impObj =
        (ims.configuration.ImportedObject)
            domMap.get(keyClassName + "_" + externalSource + "_" + this.getId());
    if (impObj == null) {
      impObj = new ims.configuration.ImportedObject();
      impObj.setExternalId(this.getId());
      impObj.setExternalSource(externalSource);
      impObj.setDomainObject(this);
      impObj.setLocalId(this.getId());
      impObj.setClassName(keyClassName);
      domMap.put(keyClassName + "_" + externalSource + "_" + this.getId(), impObj);
    }

    return sb.toString();
  }
コード例 #4
1
 public void addHashtagsFromMessage(String message) {
   if (message == null) {
     return;
   }
   boolean changed = false;
   Pattern pattern = Pattern.compile("(^|\\s)#[\\w@\\.]+");
   Matcher matcher = pattern.matcher(message);
   while (matcher.find()) {
     int start = matcher.start();
     int end = matcher.end();
     if (message.charAt(start) != '@' && message.charAt(start) != '#') {
       start++;
     }
     String hashtag = message.substring(start, end);
     if (hashtagsByText == null) {
       hashtagsByText = new HashMap<>();
       hashtags = new ArrayList<>();
     }
     HashtagObject hashtagObject = hashtagsByText.get(hashtag);
     if (hashtagObject == null) {
       hashtagObject = new HashtagObject();
       hashtagObject.hashtag = hashtag;
       hashtagsByText.put(hashtagObject.hashtag, hashtagObject);
     } else {
       hashtags.remove(hashtagObject);
     }
     hashtagObject.date = (int) (System.currentTimeMillis() / 1000);
     hashtags.add(0, hashtagObject);
     changed = true;
   }
   if (changed) {
     putRecentHashtags(hashtags);
   }
 }
コード例 #5
1
  @Override
  @SuppressWarnings("unchecked")
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    LogUtils.logd(TAG, "[onActivityCreated]");

    mSession = JRSession.getInstance();

    if (savedInstanceState != null) {
      mManagedDialogs = (HashMap) savedInstanceState.get(KEY_MANAGED_DIALOGS);
      Parcelable[] p = savedInstanceState.getParcelableArray(KEY_MANAGED_DIALOG_OPTIONS);
      if (mManagedDialogs != null && p != null) {
        for (Parcelable p_ : p) {
          Bundle b = (Bundle) p_;
          mManagedDialogs.get(b.getInt(KEY_DIALOG_ID)).mOptions = b;
        }
      } else {
        mManagedDialogs = new HashMap<Integer, ManagedDialog>();
      }
    }

    for (ManagedDialog d : mManagedDialogs.values()) {
      d.mDialog = onCreateDialog(d.mId, d.mOptions);
      if (d.mShowing) d.mDialog.show();
    }
  }
コード例 #6
1
  public static void execute(String[] args) {

    try {

      String hs2mmFile = args[0];
      HashMap human2mouse = human2mouse(hs2mmFile);
      String inputFile = args[1];
      String outputFile = args[2];
      FileWriter fwriter = new FileWriter(outputFile);
      BufferedWriter out = new BufferedWriter(fwriter);

      FileInputStream fstream = new FileInputStream(inputFile);
      DataInputStream din = new DataInputStream(fstream);
      BufferedReader in = new BufferedReader(new InputStreamReader(din));
      while (in.ready()) {
        String str = in.readLine();
        String[] split = str.split("\t");
        out.write(split[0] + "\t" + split[1]);
        for (int i = 2; i < split.length; i++) {
          if (human2mouse.containsKey(split[i])) {
            out.write("\t" + (String) human2mouse.get(split[i]));
          }
        }
        out.write("\n");
      }
      in.close();
      out.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #7
1
 public Map<String, String> getRequiredFields() {
   HashMap<String, String> fields = new HashMap<String, String>();
   for (String key : _requiredFields.stringPropertyNames()) {
     fields.put(key, _requiredFields.getProperty(key));
   }
   return fields;
 }
コード例 #8
0
 static long go(int c0, int c1, int c2, int c3, int c4, int direction) {
   if (c0 < 0 || c1 < 0 || c2 < 0 || c3 < 0 || c4 < 0) {
     return 0;
   }
   if (c0 == 0 && c1 == 0 && c2 == 0 && c3 == 0 && c4 == 0) {
     return 1;
   }
   int code = encode(c0, c1, c2, c3, c4, direction);
   Long ret = history.get(code);
   if (ret != null) {
     return ret;
   }
   long result;
   if (direction == 0) {
     result = go(c0, c1, c2, c3, c4 - 1, 4) + go(c0 - 1, c1, c2, c3, c4, 1);
   } else if (direction == 1) {
     result = go(c0 - 1, c1, c2, c3, c4, 0) + go(c0, c1 - 1, c2, c3, c4, 2);
   } else if (direction == 2) {
     result = go(c0, c1 - 1, c2, c3, c4, 1) + go(c0, c1, c2 - 1, c3, c4, 3);
   } else if (direction == 3) {
     result = go(c0, c1, c2 - 1, c3, c4, 2) + go(c0, c1, c2, c3 - 1, c4, 4);
   } else {
     result = go(c0, c1, c2, c3 - 1, c4, 3) + go(c0, c1, c2, c3, c4 - 1, 0);
   }
   history.put(code, result);
   return result;
 }
コード例 #9
0
  public void save(T media) throws IOException {

    if (!canSaveType(media.getClass())) {
      return;
    }

    String preName = media.getPreviousName();
    File f = null;

    if (fileCache.containsKey(media)) {
      f = fileCache.get(media);
    } else {
      f = generateSaveFile(media);
    }

    Gson gson =
        new GsonBuilder().excludeFieldsWithoutExposeAnnotation().setPrettyPrinting().create();
    media.setSaved(true);
    String json = gson.toJson(media);

    BufferedWriter bfw = new BufferedWriter(new FileWriter(f));
    bfw.write(json);
    bfw.close();

    if (MediaBase.class.isAssignableFrom(media.getClass())) {
      ((MediaBase) media).save();
      System.out.println("Thumb saved");
    }

    if (preName != null && !preName.equals(media.getSaveString())) {
      deleteOldVersion(media, preName);
    }
  }
コード例 #10
0
ファイル: Codecs.java プロジェクト: KhalidElSayed/lumicall
  public static void check() {
    HashMap<String, String> old = new HashMap<String, String>(codecs.size());

    for (Codec c : codecs) {
      c.update();
      old.put(c.name(), c.getValue());
      if (!c.isLoaded()) {
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(Receiver.mContext);
        SharedPreferences.Editor e = sp.edit();

        e.putString(c.key(), "never");
        e.commit();
      }
    }

    for (Codec c : codecs)
      if (!old.get(c.name()).equals("never")) {
        c.init();
        if (c.isLoaded()) {
          SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(Receiver.mContext);
          SharedPreferences.Editor e = sp.edit();

          e.putString(c.key(), old.get(c.name()));
          e.commit();
          c.init();
        } else c.fail();
      }
  }
コード例 #11
0
  /**
   * A method to build four coordinates representing a bounding box given a start coordinate and a
   * distance
   *
   * @param latitude a latitude coordinate in decimal notation
   * @param longitude a longitude coordinate in decimal notation
   * @param distance the distance to add in metres
   * @return a hashMap representing the bounding box (NE,SE,SW,NW)
   */
  public static java.util.HashMap<String, Coordinate> getBoundingBox(
      float latitude, float longitude, int distance) {

    // check on the parameters
    if (isValidLatitude(latitude) == false
        || isValidLongitude(longitude) == false
        || distance <= 0) {
      throw new IllegalArgumentException("All parameters are required and must be valid");
    }

    // convert the distance from metres to kilometers
    float kilometers = distance / 1000;

    // declare helper variables
    java.util.HashMap<String, Coordinate> boundingBox = new java.util.HashMap<String, Coordinate>();

    // calculate the coordinates
    Coordinate north = addDistanceNorth(latitude, longitude, distance);
    Coordinate south = addDistanceSouth(latitude, longitude, distance);
    Coordinate east = addDistanceEast(latitude, longitude, distance);
    Coordinate west = addDistanceWest(latitude, longitude, distance);

    // build the bounding box object
    boundingBox.put("NE", new Coordinate(north.getLatitude(), east.getLongitude()));
    boundingBox.put("SE", new Coordinate(south.getLatitude(), east.getLongitude()));
    boundingBox.put("SW", new Coordinate(south.getLatitude(), west.getLongitude()));
    boundingBox.put("NW", new Coordinate(north.getLatitude(), west.getLongitude()));

    // return the bounding box object
    return boundingBox;
  }
コード例 #12
0
ファイル: RateCodesDAO.java プロジェクト: muraleekrish/pric
 public HashMap getAllRateCodes() {
   /**
    * Requires - Modifies - Effects -
    *
    * @throws -
    */
   Criteria objCriteria = null;
   Session objSession = null;
   Integer totRecordCount = null;
   List objList = null;
   HashMap hmResult = new HashMap();
   try {
     logger.info("GETTING ALL RATE CODES");
     objSession = HibernateUtil.getSession();
     objCriteria = objSession.createCriteria(RateCodesVO.class);
     totRecordCount = new Integer(objCriteria.list().size());
     objList = objCriteria.list();
     hmResult.put("TotalRecordCount", totRecordCount);
     hmResult.put("Records", objList);
     logger.info("GOT ALL RATE CODES");
   } catch (HibernateException e) {
     logger.error("HIBERNATE EXCEPTION DURING GET ALL RATE CODES", e);
     e.printStackTrace();
   } finally {
     if (objSession != null) {
       objSession.close();
     }
   }
   return hmResult;
 }
コード例 #13
0
ファイル: ScriptLoader.java プロジェクト: aschearer/ReadyMade
  /**
   * Retrieve a list of name-script key-value pairs.
   *
   * @return
   */
  public final Map<String, String> loadScripts() {
    HashMap<String, String> scripts = new HashMap<String, String>();
    try {
      URL url = this.getClass().getClassLoader().getResource(this.directory);
      if (url == null) {
        throw new RuntimeException("The following directory was not found: " + this.directory);
      }

      URI uri = new URI(url.toString());

      File directory = new File(uri);
      FilenameFilter filter = new JavascriptFilter();

      for (String file : directory.list(filter)) {
        String script = this.readScript(directory, file);

        int dotIndex = file.lastIndexOf('.');
        scripts.put(file.substring(0, dotIndex), script.toString());
      }
    } catch (URISyntaxException e) {
      e.printStackTrace();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }

    return scripts;
  }
コード例 #14
0
 public int nameToIdx(String name) {
   if (nameMap.containsKey(name)) {
     return nameMap.get(name);
   } else {
     return -1;
   }
 }
コード例 #15
0
 @Override
 public void handle(Request request, Response response) {
   String virtualHost = request.getPath().getHost();
   if (handlers.containsKey(virtualHost)) {
     logger.debug("a virtual host handler found");
     NanoHandler handler = handlers.get(virtualHost);
     NanoSessionManager nanoSessionManager = null;
     if (handler instanceof NanoSession) {
       if (nanoSessionHandler != null) {
         nanoSessionManager = nanoSessionHandler.parseRequest(request);
       }
       ((NanoSession) handler).setNanoSessionManager(nanoSessionManager);
     }
     handler.handle(request, response);
     if (handler instanceof NanoSession) {
       if (nanoSessionHandler != null) {
         nanoSessionHandler.parseResponse(nanoSessionManager, response);
       }
     }
     logger.debug("request handled");
     return;
   }
   logger.debug("redirected to default logger");
   defaultHandler.handle(request, response);
 }
コード例 #16
0
ファイル: SVGUniverse.java プロジェクト: uazure/josm
  void registerImage(URL imageURL) {
    if (loadedImages.containsKey(imageURL)) {
      return;
    }

    SoftReference ref;
    try {
      String fileName = imageURL.getFile();
      if (".svg".equals(fileName.substring(fileName.length() - 4).toLowerCase())) {
        SVGIcon icon = new SVGIcon();
        icon.setSvgURI(imageURL.toURI());

        BufferedImage img =
            new BufferedImage(
                icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = img.createGraphics();
        icon.paintIcon(null, g, 0, 0);
        g.dispose();
        ref = new SoftReference(img);
      } else {
        BufferedImage img = ImageIO.read(imageURL);
        ref = new SoftReference(img);
      }
      loadedImages.put(imageURL, ref);
    } catch (Exception e) {
      Logger.getLogger(SVGConst.SVG_LOGGER)
          .log(Level.WARNING, "Could not load image: " + imageURL, e);
    }
  }
コード例 #17
0
  /**
   * fills the list with stops from the local database
   *
   * @param db the database adapter to use
   */
  private void fillList(BusDbAdapter db) {
    Cursor c;
    if (listType == FAVORITES) {
      c = db.getFavoriteDest(NUM_ENTRIES_TO_FETCH);
    } else { // listType == MAJOR
      c = db.getMajorDest(NUM_ENTRIES_TO_FETCH);
    }
    int stopIDIndex = c.getColumnIndex("stop_id");
    int stopDescIndex = c.getColumnIndex("stop_desc");
    int routeIDIndex = c.getColumnIndex("route_id");
    int routeDescIndex = c.getColumnIndex("route_desc");
    if (c != null) {
      for (int i = 0; i < c.getCount(); i++) {
        HashMap<String, String> item = new HashMap<String, String>();

        String stopID = c.getString(stopIDIndex);
        String stopName = c.getString(stopDescIndex);
        String route = c.getString(routeIDIndex);
        String routeDesc = c.getString(routeDescIndex);
        Log.v(TAG, "PUT");
        Log.v(TAG, "stopID " + stopID + " stopName " + stopName);
        Log.v(TAG, "routeID " + route + " routeDesc" + routeDesc);
        item.put("stopID", stopID);
        item.put("stopName", stopName);
        item.put("routeID", route);
        item.put("routeDesc", routeDesc);
        c.moveToNext();
        locationList.add(item);
      }
      listAdapter.notifyDataSetChanged();
    }
  }
コード例 #18
0
ファイル: Engine.java プロジェクト: desko27/LittleSpaceships
  public void do_alarms() {

    // every entry may be re-added immediately after its method execution, so it's safe
    // to iterate over a copy of the hashmap
    HashMap<String, Integer> local_alarm = new HashMap<>(alarm);

    // iterate through the hashmap
    for (Map.Entry a : local_alarm.entrySet()) {
      if ((int) a.getValue() <= 0) {

        // remove the executed alarm
        alarm.remove(a.getKey().toString());

        // execute alarm method
        Method method;
        //noinspection TryWithIdenticalCatches
        try {
          method = this.getClass().getMethod("alarm_" + a.getKey());
          method.invoke(this);
        } catch (NoSuchMethodException e) {
          e.printStackTrace();
        } catch (IllegalAccessException e) {
          e.printStackTrace();
        } catch (InvocationTargetException e) {
          e.printStackTrace();
        }

      } else

        // decrease the alarm timer
        alarm.put(a.getKey().toString(), (int) a.getValue() - 1);
    }
  }
コード例 #19
0
  /**
   * @param url The URL of the image that will be retrieved from the cache.
   * @return The cached bitmap or null if it was not found.
   */
  private Bitmap getBitmapFromCache(String url) {
    // First try the hard reference cache
    synchronized (sHardBitmapCache) {
      final Bitmap bitmap = sHardBitmapCache.get(url);
      if (bitmap != null) {
        // Bitmap found in hard cache
        // Move element to first position, so that it is removed last
        sHardBitmapCache.remove(url);
        sHardBitmapCache.put(url, bitmap);
        return bitmap;
      }
    }

    // Then try the soft reference cache
    SoftReference<Bitmap> bitmapReference = sSoftBitmapCache.get(url);
    if (bitmapReference != null) {
      final Bitmap bitmap = bitmapReference.get();
      if (bitmap != null) {
        // Bitmap found in soft cache
        return bitmap;
      } else {
        // Soft reference has been Garbage Collected
        sSoftBitmapCache.remove(url);
      }
    }

    return null;
  }
コード例 #20
0
  public static void registerHotKey(KeyStroke stroke, final ActionBase ab) {
    // under windows, use hotkey that can be used even when window
    // has not the focus. Note that all keys are nor hotkeys (given
    // by bHotkey flag)
    int index = hmIndexAction.size() - 1;
    jintellitype.registerSwingHotKey(index + 1, stroke.getModifiers(), stroke.getKeyCode());
    // register the action with its index
    hmIndexAction.put(index + 1, ab);
    // add the listener
    jintellitype.addHotKeyListener(
        new HotkeyListener() {

          public void onHotKey(int key) {
            // Leave if user disabled hotkeys
            if (!ConfigurationManager.getBoolean(CONF_OPTIONS_HOTKEYS)) {
              return;
            }
            // Check it is the right listener that caught the event
            if (ab.equals(hmIndexAction.get(key))) {
              try {
                // Call action itself
                ab.perform(null);
              } catch (Throwable e2) {
                Log.error(e2);
              } finally {
                ObservationManager.notify(new Event(EventSubject.EVENT_PLAYLIST_REFRESH));
              }
            }
          }
        });
  }
コード例 #21
0
  /**
   * ************************************************************************ Get the database path
   * for this project
   *
   * @return ***********************************************************************
   */
  @SuppressWarnings("unchecked")
  public String getDatabasePath() {
    HashMap<QualifiedName, Object> properties = null;
    try {
      properties = new HashMap<QualifiedName, Object>(m_project.getPersistentProperties());
    } catch (CoreException e1) {
      System.err.println(
          "Cannot retrieve persistent properties for project " + m_project.getName());
      return null;
    }
    if (!properties.containsKey(ProjectDatabaseProperty.GCS_DATABASE.getKey())) {
      restoreProjectProperties(ProjectDatabaseProperty.GCS_DATABASE);
    }

    try {
      String path = m_project.getPersistentProperty(ProjectDatabaseProperty.GCS_DATABASE.getKey());
      // Relative path
      boolean absolute = true;
      if (!path.isEmpty()) {
        absolute = new File(path).isAbsolute();
      }
      if (!path.isEmpty() && !absolute) {
        IPath projAbsolute = m_project.getLocation();
        String projectPath = projAbsolute.toFile().getAbsolutePath();
        path = projectPath + File.separator + path;
      }
      return path;
    } catch (CoreException e) {
      return null;
    }
  }
コード例 #22
0
  public static Response importFeatures(
      String spatialcontext,
      String data,
      String format,
      String srid,
      String creator,
      String license) {
    try (Database db = new Database()) {
      String[] split = data.split("\\r?\\n");
      for (String content : split) {
        int fid = db.addFeature(spatialcontext, content, format, Integer.parseInt(srid));
        db.addImport(fid, creator, license);

        // TODO: Visibility Analysis
        GeoFeature feature = db.getFeature(spatialcontext, fid);
        HashMap<String, Double> visibility = checkVisibility(spatialcontext, feature, db, null);
        for (String vp : visibility.keySet()) {
          db.setVisibility(spatialcontext, fid, vp, visibility.get(vp) > VISIBILITY_TOLERANCE);
        }
      }
      db.close();
      return Config.getResult();
      // return
      // Response.seeOther(URI.create(Config.getProperty("gv_viewer"))).header("Access-Control-Allow-Origin", "*").build();
    } catch (ClientException e) {
      return Config.getResult(e);
    } catch (Exception e) {
      return Config.getResult(e);
    }
  }
コード例 #23
0
  private static void add(
      Map<String, HashMap<String, CalibrationStats>> thresholds,
      String sampleId,
      String sequenceName,
      CalibrationStats covariateValues) {
    final HashMap<String, CalibrationStats> map;
    if (thresholds.containsKey(sampleId)) {
      map = thresholds.get(sampleId);
    } else {
      map = new HashMap<>();
      thresholds.put(sampleId, map);
    }

    if (map.containsKey(sequenceName)) {
      if (covariateValues != null) {
        map.get(sequenceName).accumulate(covariateValues);
      }
    } else {
      final CalibrationStats stats = new CalibrationStats(null);
      if (covariateValues != null) {
        stats.accumulate(covariateValues);
      }
      map.put(sequenceName, stats);
    }
  }
コード例 #24
0
  private static String doSomething(String param) throws ServletException, IOException {

    // Chain a bunch of propagators in sequence
    String a47625 = param; // assign
    StringBuilder b47625 = new StringBuilder(a47625); // stick in stringbuilder
    b47625.append(" SafeStuff"); // append some safe content
    b47625.replace(
        b47625.length() - "Chars".length(),
        b47625.length(),
        "Chars"); // replace some of the end content
    java.util.HashMap<String, Object> map47625 = new java.util.HashMap<String, Object>();
    map47625.put("key47625", b47625.toString()); // put in a collection
    String c47625 = (String) map47625.get("key47625"); // get it back out
    String d47625 = c47625.substring(0, c47625.length() - 1); // extract most of it
    String e47625 =
        new String(
            new sun.misc.BASE64Decoder()
                .decodeBuffer(
                    new sun.misc.BASE64Encoder()
                        .encode(d47625.getBytes()))); // B64 encode and decode it
    String f47625 = e47625.split(" ")[0]; // split it on a space
    org.owasp.benchmark.helpers.ThingInterface thing =
        org.owasp.benchmark.helpers.ThingFactory.createThing();
    String bar = thing.doSomething(f47625); // reflection

    return bar;
  }
コード例 #25
0
 public static int getPartyActivationLevelForPartyRole(String partyRoleCode) throws Exception {
   int activationLevel = 0;
   if (partyRoleCode != null && !"".equals(partyRoleCode)) {
     if (roleActivationLevelMap.containsKey(partyRoleCode)) {
       activationLevel = ((Integer) roleActivationLevelMap.get(partyRoleCode)).intValue();
     } else if (roleActivationLevelMap.size() == 0) {
       try {
         LogicModuleService lms = LogicModuleServiceUtil.getHome().create();
         ObjectQueryCommand additionalCommand =
             new ObjectQueryCommand("com.foursoft.etrans.entities.PartyRoleType", Locale.US);
         additionalCommand.setAttributeNames(new String[] {"code", "roleDependencyIndicator"});
         additionalCommand.sethasLocaleData(false);
         Object[][] data = lms.getTableModel(additionalCommand).getData();
         if (data != null && data.length > 0) {
           for (int i = 0; i < data.length; i++) {
             String code = (String) data[i][0];
             Integer roleActivationLevel =
                 (Integer) ((RoleDependencyIndicatorEnumeration) data[i][1]).getEnumCode();
             if (code != null && !"".equals(code) && roleActivationLevel != null) {
               if (partyRoleCode.equals(code)) activationLevel = roleActivationLevel.intValue();
               roleActivationLevelMap.put(code, roleActivationLevel);
             }
           }
         }
       } finally {
       }
     }
   }
   return activationLevel;
 }
コード例 #26
0
ファイル: SVGUniverse.java プロジェクト: uazure/josm
  /**
   * Returns the diagram that has been loaded from this root. If diagram is not already loaded,
   * returns null.
   */
  public SVGDiagram getDiagram(URI xmlBase, boolean loadIfAbsent) {
    if (xmlBase == null) {
      return null;
    }

    SVGDiagram dia = (SVGDiagram) loadedDocs.get(xmlBase);
    if (dia != null || !loadIfAbsent) {
      return dia;
    }

    // Load missing diagram
    try {
      URL url;
      if ("jar".equals(xmlBase.getScheme())
          && xmlBase.getPath() != null
          && !xmlBase.getPath().contains("!/")) {
        // Workaround for resources stored in jars loaded by Webstart.
        // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6753651
        url = SVGUniverse.class.getResource("xmlBase.getPath()");
      } else {
        url = xmlBase.toURL();
      }

      loadSVG(url, false);
      dia = (SVGDiagram) loadedDocs.get(xmlBase);
      return dia;
    } catch (Exception e) {
      Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, "Could not parse", e);
    }

    return null;
  }
コード例 #27
0
  @Override
  public ArrayList<Datum> readOneTuple() {
    if (buffer == null) return null;
    String line = null;

    try {
      line = buffer.readLine();
    } catch (IOException e) {
      //			e.printStackTrace();
      return null;
    }

    if (line == null || line.isEmpty()) {
      try {
        buffer.close();
        return null;
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      return null;
    }

    String col[] = line.split("\\|");
    ArrayList<Datum> tuples = new ArrayList<>();
    for (int counter = 0; counter < col.length; counter++) {
      if (indexMaps.containsKey(counter)) {
        String type = indexMaps.get(counter);
        tuples.add(new Datum(type.toLowerCase(), col[counter]));
      }
    }
    return tuples;
  }
コード例 #28
0
  @Override
  public void authRequest(Uri url, HashMap<String, String> doneSoFar) {
    if (mProgressDialog.isShowing()) {
      // should always be showing here
      mProgressDialog.dismiss();
    }

    // add our list of completed uploads to "completed"
    // and remove them from our toSend list.
    ArrayList<Long> workingSet = new ArrayList<Long>();
    Collections.addAll(workingSet, mInstancesToSend);
    if (doneSoFar != null) {
      Set<String> uploadedInstances = doneSoFar.keySet();
      Iterator<String> itr = uploadedInstances.iterator();

      while (itr.hasNext()) {
        Long removeMe = Long.valueOf(itr.next());
        boolean removed = workingSet.remove(removeMe);
        if (removed) {
          Log.i(t, removeMe + " was already sent, removing from queue before restarting task");
        }
      }
      mUploadedInstances.putAll(doneSoFar);
    }

    // and reconstruct the pending set of instances to send
    Long[] updatedToSend = new Long[workingSet.size()];
    for (int i = 0; i < workingSet.size(); ++i) {
      updatedToSend[i] = workingSet.get(i);
    }
    mInstancesToSend = updatedToSend;

    mUrl = url.toString();
    showDialog(AUTH_DIALOG);
  }
コード例 #29
0
  @GET
  @Path("/{reviewId}")
  @Timed(name = "view-book-by-reviewId")
  public Response viewBookReview(
      @PathParam("isbn") LongParam isbn, @PathParam("reviewId") IntParam reviewId) {

    Book book = bookRepository.getBookByISBN(isbn.get());

    ReviewDto reviewResponse = null;
    List<Review> reviewList = book.getReview();

    List<Review> tempList = new ArrayList<Review>();
    for (Review reviewObj : reviewList) {

      if (reviewObj.getId() == reviewId.get()) tempList.add(reviewObj);
    }
    reviewResponse = new ReviewDto(tempList);
    String location = "/books/" + book.getIsbn() + "/reviews/";

    HashMap<String, Object> map = new HashMap<String, Object>();

    Review review = reviewResponse.getReviewList().get(0);
    map.put("review", review);
    reviewResponse.addLink(new LinkDto("view-review", location + reviewId.get(), "GET"));
    map.put("links", reviewResponse.getLinks());
    return Response.status(200).entity(map).build();
  }
コード例 #30
0
 static {
   sHistoryProjectionMap = new HashMap<String, String>();
   sHistoryProjectionMap.put(ChatHistoryTable._ID, ChatHistoryTable._ID);
   sHistoryProjectionMap.put(ChatHistoryTable.CHAT_ASK, ChatHistoryTable.CHAT_ASK);
   sHistoryProjectionMap.put(ChatHistoryTable.CHAT_ANSWER, ChatHistoryTable.CHAT_ANSWER);
   sHistoryProjectionMap.put(ChatHistoryTable.CHAT_TIME, ChatHistoryTable.CHAT_TIME);
 }