Exemplo n.º 1
0
  private void ListSubDirectorySizes(File file) {
    File[] files;
    files =
        file.listFiles(
            new FileFilter() {
              @Override
              public boolean accept(File file) {
                //                if (!file.isDirectory()){
                //                    return false;  //To change body of implemented methods use
                // File | Settings | File Templates.
                //                }else{
                //                    return true;
                //                }
                return true;
              }
            });
    Map<String, Long> dirListing = new HashMap<String, Long>();
    for (File dir : files) {
      DiskUsage diskUsage = new DiskUsage();
      diskUsage.accept(dir);
      //            long size = diskUsage.getSize() / (1024 * 1024);
      long size = diskUsage.getSize();
      dirListing.put(dir.getName(), size);
    }

    ValueComparator bvc = new ValueComparator(dirListing);
    TreeMap<String, Long> sorted_map = new TreeMap<String, Long>(bvc);
    sorted_map.putAll(dirListing);

    PrettyPrint(file, sorted_map);
  }
Exemplo n.º 2
0
 /** Print a full description of all elements in the Tdb */
 public void prettyPrint(PrintStream ps) {
   ps.println("Tdb");
   TreeMap<String, TdbPublisher> sorted =
       new TreeMap<String, TdbPublisher>(CatalogueOrderComparator.SINGLETON);
   sorted.putAll(getAllTdbPublishers());
   for (TdbPublisher tdbPublisher : sorted.values()) {
     tdbPublisher.prettyPrint(ps, 2);
   }
 }
Exemplo n.º 3
0
 public static void sortAndPrintMap(Map<String, Double> map) throws FileNotFoundException {
   // pr = new PrintStream(new FileOutputStream("/semplest/lluis/keywordExp/wordmap.txt"));
   pr = System.out;
   ValueComparator bvc = new ValueComparator(map);
   TreeMap<String, Double> sorted = new TreeMap<String, Double>(bvc);
   sorted.putAll(map);
   for (String key : sorted.keySet()) {
     pr.println(key + " : " + map.get(key));
   }
   System.out.println("Number of words : " + map.size());
 }
Exemplo n.º 4
0
  /** Replace working files with the selected checked-in files. */
  @Override
  public void doApply() {
    super.doApply();

    if (pIsFrozen) return;

    TreeMap<String, VersionID> files = new TreeMap<String, VersionID>();
    for (JFileSeqPanel panel : pFileSeqPanels.values()) files.putAll(panel.getFilesToRevert());

    RevertTask task = new RevertTask(files);
    task.start();
  }
Exemplo n.º 5
0
  /**
   * Draws the GUI that allows a user to select assets to be updated.
   *
   * @return true if the user made a valid choice of assets to replace.
   * @throws PipelineException
   */
  private boolean buildUpdateGUI() throws PipelineException {
    Box finalBox = new Box(BoxLayout.Y_AXIS);
    top = new Box(BoxLayout.Y_AXIS);

    JScrollPane scroll;

    {
      scroll = new JScrollPane(finalBox);

      scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
      scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

      Dimension size = new Dimension(sVSize + sVSize + sTSize + 52, 500);
      scroll.setMinimumSize(size);
      scroll.setPreferredSize(size);
      scroll.getViewport().setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE);
    }

    /* query the user */
    diag = new JToolDialog("Propagate Asset", scroll, "Continue");

    areas = mclient.getWorkingAreas();
    {
      Box hbox = new Box(BoxLayout.X_AXIS);
      Component comps[] = UIFactory.createTitledPanels();
      JPanel tpanel = (JPanel) comps[0];
      JPanel vpanel = (JPanel) comps[1];
      {
        userField =
            UIFactory.createTitledCollectionField(
                tpanel,
                "User:"******"The user whose area the node is being created in.");
        userField.setActionCommand("user");
        userField.setSelected(PackageInfo.sUser);
        userField.addActionListener(this);
      }
      UIFactory.addVerticalSpacer(tpanel, vpanel, 3);
      {
        viewField =
            UIFactory.createTitledCollectionField(
                tpanel,
                "View:",
                sTSize,
                vpanel,
                areas.get(PackageInfo.sUser),
                diag,
                sVSize,
                "The working area to create the nodes in.");
        viewField.setActionCommand("wrap");
        viewField.addActionListener(this);
      }
      UIFactory.addVerticalSpacer(tpanel, vpanel, 3);
      {
        toolsetField =
            UIFactory.createTitledCollectionField(
                tpanel,
                "Toolset:",
                sTSize,
                vpanel,
                mclient.getActiveToolsetNames(),
                diag,
                sVSize,
                "The toolset to set on all the nodes.");
        toolsetField.setSelected(mclient.getDefaultToolsetName());
        toolsetField.setActionCommand("wrap");
        toolsetField.addActionListener(this);
      }
      UIFactory.addVerticalSpacer(tpanel, vpanel, 3);

      w =
          new Wrapper(
              userField.getSelected(),
              viewField.getSelected(),
              toolsetField.getSelected(),
              mclient);

      charList = SonyConstants.getAssetList(w, project, AssetType.CHARACTER);
      setsList = SonyConstants.getAssetList(w, project, AssetType.SET);
      propsList = SonyConstants.getAssetList(w, project, AssetType.PROP);

      {
        projectField =
            UIFactory.createTitledCollectionField(
                tpanel,
                "Project:",
                sTSize,
                vpanel,
                Globals.getChildrenDirs(w, "/projects"),
                diag,
                sVSize,
                "All the projects in pipeline.");
        projectField.setActionCommand("proj");
        projectField.addActionListener(this);
      }
      hbox.add(comps[2]);
      top.add(hbox);
    }

    {
      Box vbox = new Box(BoxLayout.Y_AXIS);
      Box hbox = new Box(BoxLayout.X_AXIS);
      JButton button = new JButton("Propagate Additional Asset");
      button.setName("ValuePanelButton");
      button.setRolloverEnabled(false);
      button.setFocusable(false);
      Dimension d = new Dimension(sVSize, 25);
      button.setPreferredSize(d);
      button.setMinimumSize(d);
      button.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25));

      vbox.add(Box.createRigidArea(new Dimension(0, 5)));
      hbox.add(button);
      hbox.add(Box.createRigidArea(new Dimension(4, 0)));
      vbox.add(hbox);
      vbox.add(Box.createRigidArea(new Dimension(0, 5)));

      button.setActionCommand("add");
      button.addActionListener(this);

      top.add(vbox);
    }

    list = new Box(BoxLayout.Y_AXIS);
    test = new JDrawer("Propagate Additional Asset", list, false);

    top.add(test);
    list.add(assetChoiceBox());

    finalBox.add(top);

    {
      JPanel spanel = new JPanel();
      spanel.setName("Spacer");
      spanel.setMinimumSize(new Dimension(sTSize + sVSize, 7));
      spanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
      spanel.setPreferredSize(new Dimension(sTSize + sVSize, 7));
      finalBox.add(spanel);
    }

    diag.setVisible(true);
    if (diag.wasConfirmed()) {
      // get list of things to change.
      for (Component comp : list.getComponents()) {
        if (comp instanceof Box) {
          Box can = (Box) comp;
          JCollectionField oldOne = (JCollectionField) can.getComponent(2);
          JCollectionField newOne = (JCollectionField) can.getComponent(4);

          TreeMap<String, String> assetList = new TreeMap<String, String>();
          assetList.putAll(charList);
          assetList.putAll(propsList);
          assetList.putAll(setsList);

          String key = assetList.get(oldOne.getSelected()) + lr;
          String value = assetList.get(newOne.getSelected()) + lr;
          if (!key.equals(value)) {
            potentialUpdates.add(key);
            pAssetManager.put(key, new AssetInfo(key, value));
          }
          // System.err.println("bUG: "+pAssetManager.get(key).getHiLoResShots());
        }
      }

      if (!pAssetManager.isEmpty()) return true;
    }
    return false;
  } // end buildReplacementGUI
  @SuppressWarnings({"unchecked", "rawtypes"})
  public List<String> getBestMatchingScore(String indexfile, String queryfile, String num)
      throws IOException, ClassNotFoundException {

    //        try {
    int count = Integer.parseInt(num);

    // String cur_dir = "D:\\STS_Workspace\\IRSearch_PraneethReddyVellaboyana"; cur_dir + "\\" +
    // System.out.println("!!!!!!!!!!!!!!!!"+cur_dir);
    FileInputStream fileIn = new FileInputStream(IntegerConstants.cur_dir + indexfile);
    ObjectInputStream in = new ObjectInputStream(fileIn);
    inv_index = (TreeMap) in.readObject();
    System.out.println(inv_index);

    tokenCount = (TreeMap) in.readObject();

    System.out.println(tokenCount);
    // Total number of words in all the documents
    int totalTokenCount = 0;

    // Calculate the total number of tokens in the collection
    for (Iterator i = tokenCount.entrySet().iterator(); i.hasNext(); ) {
      Map.Entry next = (Map.Entry) i.next();
      totalTokenCount = totalTokenCount + (Integer) next.getValue();
    }
    // average  document length
    Double avdl = totalTokenCount * 1.0 / tokenCount.size();

    // Reading a file cur_dir + "\\" +
    File qf = new File(IntegerConstants.cur_dir + queryfile);
    BufferedReader bf = new BufferedReader(new FileReader(qf));

    String querytext;

    int queryid = 1;
    while ((querytext = bf.readLine()) != null) {

      String[] querywords = querytext.split(" ");

      // Step1: Retrieve all inverted lists corresponding to terms in a query.
      for (String word1 : querywords) {

        PorterStemmer ps = new PorterStemmer();
        String word = ps.stem(word1);

        word = word.trim();
        if (!word.equals("") && inv_index.containsKey(word)) {
          query_index.put(word, inv_index.get(word));
        }
      }

      // Step2: Compute BM25 scores for documents in the lists.
      for (Iterator iterator1 = query_index.entrySet().iterator(); iterator1.hasNext(); ) {
        // next contains list of files for the query word and their occurrences in each file
        Map.Entry next = (Map.Entry) iterator1.next();
        TreeMap indexes = (TreeMap) next.getValue();
        for (Iterator iterator2 = indexes.entrySet().iterator(); iterator2.hasNext(); ) {
          Map.Entry next2 = (Map.Entry) iterator2.next();
          // number of words of the query in the document
          int fi = (Integer) next2.getValue();
          //  total number of documents
          int N = tokenCount.size();
          // number of files the query word occurred in
          int ni = indexes.size();
          Double qfi = 0.0;

          // Number of words in the query string
          for (int i = 0; i < querywords.length; i++) {
            // matching the query word with the index of the queries to count the matched and
            // revelent query
            if (querytext.contains(querywords[i])) {
              qfi++;
            }
          }

          // Computing K value
          Double K =
              IntegerConstants.k1
                  * ((1 - IntegerConstants.b)
                      + IntegerConstants.b * (tokenCount.get(next2.getKey()) / avdl));
          Double first_term =
              (Math.log(
                  ((IntegerConstants.ri + 0.5) / (IntegerConstants.R - IntegerConstants.ri + 0.5))
                      / ((ni - IntegerConstants.ri + 0.5)
                          / (N - ni - IntegerConstants.R + IntegerConstants.ri + 0.5))));
          Double second_term = ((IntegerConstants.k1 + 1) * fi / (K + fi));
          Double third_term = ((IntegerConstants.k2 + 1) * qfi / (IntegerConstants.k2 + qfi));
          Double total = first_term * second_term * third_term;

          if (documentScore.containsKey((String) next2.getKey())) {
            Double valueToPut = total + documentScore.get((String) next2.getKey());
            documentScore.put((String) next2.getKey(), valueToPut);
          } else {
            documentScore.put((String) next2.getKey(), total);
          }
        }
      }
      // putting all the rank in descending order using the rank
      DescendingOrder comp = new DescendingOrder((TreeMap) documentScore);
      // order document score
      TreeMap<String, Double> list_asc = new TreeMap<String, Double>(comp);
      list_asc.putAll(documentScore);

      int rank = 1;
      // iterating with respect to the number of fetch results(third) parameter from the method
      for (Iterator itr = list_asc.entrySet().iterator(); itr.hasNext() && rank <= count; ) {
        Map.Entry nx = (Map.Entry) itr.next();
        // Double bmValue = (Double) nx.getValue();
        // System.out.println(queryid + " Q0 " + nx.getKey() + " " + rank + " " + bmValue + "
        // Praneeth");
        // adding the files in the list by preserving the insertion order
        queryResults.add(nx.getKey().toString());
        rank++;
      }
      queryid++;
      documentScore.clear();
      query_index.clear();
    }

    in.close();
    fileIn.close();
    bf.close();
    return queryResults;
  }
Exemplo n.º 7
0
  /**
   * Construct a {@link SubProcessHeavy SubProcessHeavy} instance which when executed will fulfill
   * the given action agenda.
   *
   * <p>
   *
   * @param agenda The agenda to be accomplished by the action.
   * @param outFile The file to which all STDOUT output is redirected.
   * @param errFile The file to which all STDERR output is redirected.
   * @return The SubProcess which will fulfill the agenda.
   * @throws PipelineException If unable to prepare a SubProcess due to illegal, missing or
   *     imcompatable information in the action agenda or a general failure of the prep method code.
   */
  public SubProcessHeavy prep(ActionAgenda agenda, File outFile, File errFile)
      throws PipelineException {
    /* model filenames */
    TreeMap<String, Path> modelPaths = new TreeMap<String, Path>();
    TreeMap<String, Path> animPaths = new TreeMap<String, Path>();

    TreeMap<String, String> nameSpaces = new TreeMap<String, String>();
    TreeMap<String, String> reverseNameSpaces = new TreeMap<String, String>();
    TreeMap<String, Boolean> usesNameSpace = new TreeMap<String, Boolean>();
    TreeMap<String, String> buildTypes = new TreeMap<String, String>();

    for (String sname : agenda.getSourceNames()) {
      if (hasSourceParams(sname)) {
        FileSeq fseq = agenda.getPrimarySource(sname);
        String suffix = fseq.getFilePattern().getSuffix();
        if (fseq.isSingle() && (suffix != null)) {
          if (suffix.equals("ma") || suffix.equals("mb")) {
            Path npath = new Path(sname);
            String type = getSourceStringParamValue(sname, aSceneType);
            String nspace = getSourceStringParamValue(sname, aPrefixName);
            if (nspace == null) {
              nspace = npath.getName();
            }
            if (type.equals(aModel))
              modelPaths.put(sname, new Path(npath.getParentPath(), fseq.getPath(0)));
            else {
              animPaths.put(sname, new Path(npath.getParentPath(), fseq.getPath(0)));
              nspace += "_a";
            }

            boolean useNSpace = false;
            {
              Boolean tf = (Boolean) getSourceParamValue(sname, aNameSpace);
              useNSpace = ((tf != null) && tf);
            }

            String buildType = getSourceStringParamValue(sname, aBuildType);
            if (buildType == null)
              throw new PipelineException(
                  "The value of the "
                      + aBuildType
                      + " source parameter for node "
                      + "("
                      + sname
                      + ") was not set!");

            buildTypes.put(sname, buildType);
            nameSpaces.put(sname, nspace);
            reverseNameSpaces.put(nspace, sname);
            usesNameSpace.put(sname, useNSpace);
          }
        }
      }
    }

    /* the target Maya scene */
    Path targetScene = getMayaSceneTargetPath(agenda);
    String sceneType = getMayaSceneType(agenda);

    /* create a temporary MEL script file */
    File script = createTemp(agenda, "mel");
    try {
      FileWriter out = new FileWriter(script);

      /* provide parameters as MEL variables */
      out.write(genFrameRangeVarsMEL());

      /* rename the current scene as the output scene */
      out.write(
          "// SCENE SETUP\n"
              + "file -rename \""
              + targetScene
              + "\";\n"
              + "file -type \""
              + sceneType
              + "\";\n\n");

      out.write(genUnitsMEL());

      writeInitialMEL(agenda, out);

      /* the model file reference imports */
      TreeMap<String, Path> all = new TreeMap<String, Path>(modelPaths);
      all.putAll(animPaths);
      for (String sname : all.keySet()) {
        Path mpath = all.get(sname);

        String buildType = buildTypes.get(sname);

        out.write(
            "// MODEL: "
                + sname
                + "\n"
                + "print \""
                + buildType
                + " Model: "
                + mpath
                + "\\n\";\n"
                + "file\n");

        String nspace = nameSpaces.get(sname);

        boolean useNSpace = usesNameSpace.get(sname);

        if (buildType.equals(aImport)) {
          out.write("  -import\n");

          if (useNSpace) out.write("  -namespace \"" + nspace + "\"\n");
        } else if (buildType.equals(aReference)) {
          out.write("  -reference\n");

          if (useNSpace) out.write("  -namespace \"" + nspace + "\"\n");
          else out.write("  -renamingPrefix \"" + nspace + "\"\n");
        } else {
          throw new PipelineException(
              "Unknown value for the "
                  + aBuildType
                  + " source parameter for node "
                  + "("
                  + sname
                  + ") encountered!");
        }

        {
          String fname = mpath.getName();
          if (fname.endsWith("ma")) out.write("  -type \"mayaAscii\"\n");
          else if (fname.endsWith("mb")) out.write("  -type \"mayaBinary\"\n");
          else
            throw new PipelineException(
                "Unknown Maya scene format for source file (" + mpath + ")!");
        }

        out.write("  -options \"v=0\"\n" + "  \"$WORKING" + mpath + "\";\n\n");
      }

      writeModelMEL(agenda, out);

      out.write(
          "global proc string removePrefix(string $name)\n"
              + "{\n"
              + "  string $toReturn;\n"
              + "  string $buffer[];\n"
              + "  tokenize($name, \"|\", $buffer);\n"
              + "  string $part;\n"
              + "  for ($part in $buffer) {\n"
              + "    string $buffer2[];\n"
              + "    tokenize($part, \":\", $buffer2);\n"
              + "    if ($toReturn == \"\")\n"
              + "      $toReturn += $buffer2[(size($buffer2) -1)];\n"
              + "    else\n"
              + "      $toReturn += \"|\" + $buffer2[(size($buffer2) -1)];\n"
              + "  }\n"
              + "  return $toReturn;    \n"
              + "}\n");

      out.write(
          "global proc string addPrefix(string $name, string $prefix)\n"
              + "{\n"
              + "  string $toReturn;\n"
              + "  string $buffer[];\n"
              + "  tokenize($name, \"|\", $buffer);\n"
              + "  string $part;\n"
              + "  for ($part in $buffer) {\n"
              + "    if ($toReturn == \"\")\n"
              + "      $toReturn += $prefix + $buffer[(size($buffer) -1)];\n"
              + "    else\n"
              + "      $toReturn += \"|\" + $prefix + $buffer[(size($buffer) -1)];\n"
              + "  }\n"
              + "  return $toReturn;\n"
              + "}\n");

      for (String sname : animPaths.keySet()) {
        String nspace = nameSpaces.get(sname);
        String otherNspace = nspace.substring(0, nspace.length() - 2);

        String modelName = reverseNameSpaces.get(otherNspace);

        if (modelName != null) {
          boolean useNSpace = usesNameSpace.get(sname);
          boolean otherUseNSpace = usesNameSpace.get(modelName);

          String buildType = buildTypes.get(sname);
          String otherBuildType = buildTypes.get(modelName);
          String prefix = generatePrefix(nspace, useNSpace, buildType);
          String otherPrefix = generatePrefix(otherNspace, otherUseNSpace, otherBuildType);

          out.write(
              "{\n"
                  + "  string $crvPrefix = \""
                  + prefix
                  + "\";\n"
                  + "  string $objPrefix = \""
                  + otherPrefix
                  + "\";\n"
                  + "  string $obj = $crvPrefix + \"curveInfo\";\n"
                  + "  if (`objExists $obj`) {\n"
                  + "    int $size = `getAttr -s ($obj + \".cn\")`;\n"
                  + "    int $i = 0;\n"
                  + "    for ($i = 0; $i < $size; $i++) {\n"
                  + "      string $curve = `getAttr  ($obj + \".cn[\" + $i + \"]\")`;\n"
                  + "      string $attr = `getAttr  ($obj + \".an[\" + $i + \"]\")`;\n"
                  + "      $curve =  addPrefixToName($crvPrefix, $curve);\n"
                  + "      $attr  =  addPrefixToName($objPrefix, $attr);\n"
                  + "      print(\"connectAttr -f \" + $curve + \" \" + $attr + \"\\n\");\n"
                  + "      connectAttr -f $curve $attr;   \n"
                  + "    }\n"
                  + "  }\n"
                  + "  else {\n"
                  + "    string $curves[] = `ls -type animCurve ($crvPrefix + \"*\")`;\n"
                  + "    string $curve;\n"
                  + "    for ($curve in $curves) {\n"
                  + "      string $shortName = removePrefix($curve);\n"
                  + "      string $buffer[];\n"
                  + "      tokenize($shortName, \"_\", $buffer);\n"
                  + "      string $attr = $buffer[(size($buffer) -1)];\n"
                  + "      string $name = \"\";\n"
                  + "      int $length = (size($buffer) -1);\n"
                  + "      int $i;\n"
                  + "      for ($i = 0; $i < $length; $i++) {\n"
                  + "        $name += $buffer[$i];\n"
                  + "        if ($i != ($length - 1) )\n"
                  + "          $name += \"_\";\n"
                  + "      }\n"
                  + "      string $channel = addPrefix($name, $objPrefix) + \".\" + $attr;\n"
                  + "      print ($curve + \"\\t\" + $channel + \"\\n\");\n"
                  + "      if (!`getAttr -l $channel`)\n"
                  + "        connectAttr -f ($curve + \".output\") $channel;\n"
                  + "    }\n"
                  + "  }\n"
                  + "}\n");
        }
      }

      /* set the time options */
      out.write(genPlaybackOptionsMEL());

      writeAnimMEL(agenda, out);

      /* save the file */
      out.write(
          "// SAVE\n"
              + "print \"Saving Generated Scene: "
              + targetScene
              + "\\n\";\n"
              + "file -save;\n\n");

      writeFinalMEL(agenda, out);

      out.close();
    } catch (IOException ex) {
      throw new PipelineException(
          "Unable to write temporary MEL script file ("
              + script
              + ") for Job "
              + "("
              + agenda.getJobID()
              + ")!\n"
              + ex.getMessage());
    }

    /* create the process to run the action */
    return createMayaSubProcess(null, script, true, agenda, outFile, errFile);
  }