예제 #1
0
  /**
   * Using a list of shots and the assets to be changed per shot, gets each shot node and modifies
   * the references as needed.
   */
  private void processNodes() throws PipelineException {
    /*each asset, its replacement and the lo-res versions*/
    for (String asset : pAssetManager.keySet()) {
      String newAsset = pAssetManager.get(asset).getNewAsset();
      String hrAsset = asset.replace(lr, "");
      String newHrAsset = newAsset.replace(lr, "");
      logLine(
          "Checking out nodes:\n\t"
              + asset
              + "\n\t"
              + hrAsset
              + "\n\t"
              + newAsset
              + "\n\t"
              + newHrAsset);

      mclient.checkOut(w.user, w.view, asset, null, over, froz);
      mclient.checkOut(w.user, w.view, newAsset, null, over, froz);
      mclient.checkOut(w.user, w.view, hrAsset, null, over, froz);
      mclient.checkOut(w.user, w.view, newHrAsset, null, over, froz);
    } // end for

    TreeMap<String, TreeSet<String>> shotBased = convertListToShotBased();
    TreeMap<String, String> nameMap = SonyConstants.getCustomNamespaces(project);
    TreeSet<String> oldRef = new TreeSet<String>();
    TreeSet<String> newRef = new TreeSet<String>();

    for (String shot : shotBased.keySet()) {
      // check out the shot

      if (shot.endsWith("anim")) mclient.checkOut(w.user, w.view, shot, null, keep, frozU);
      else {
        continue;
        // mclient.checkOut(w.user, w.view, shot, null, keep, pFroz);
      }
      logLine("Checking out: " + shot);

      NodeMod targetMod = mclient.getWorkingVersion(w.user, w.view, shot);
      if (!shot.matches(lgtPattern)) {

        if (targetMod.isActionEnabled()) {
          System.err.println("Anim node with action enabled");
          FileSeq fseq = targetMod.getPrimarySequence();
          VersionID targetID = targetMod.getWorkingID();
          TreeMap<String, VersionID> files = new TreeMap<String, VersionID>();
          files.put(fseq.getFile(0).getPath(), targetID);
          mclient.revertFiles(w.user, w.view, shot, files);
          targetMod.setActionEnabled(false);
        }

        w.mclient.modifyProperties(w.user, w.view, targetMod);
      }

      /*--checking the shot to be modified---*/

      for (String assetToReplace : shotBased.get(shot)) {
        if (assetToReplace.endsWith(lr)) {
          AssetInfo temp = pAssetManager.get(assetToReplace);
          oldRef.add(assetToReplace);
          newRef.add(temp.getNewAsset());
        } else {
          String hiRes = assetToReplace.replace(lr, "");
          AssetInfo temp = pAssetManager.get(hiRes);
          if (temp == null) continue;
          oldRef.add(assetToReplace);
          newRef.add(temp.getNewAsset() + lr);
        } // end else
      } // end for

      if (oldRef.isEmpty() || newRef.isEmpty()) {
        logLine("Shot " + shot + " somehow does not need any changes.");
        continue;
      } // end if

      editShotReferences(shot, targetMod, oldRef, newRef, nameMap);
    } // end for

    /*for(String shot: shotBased.keySet()){
    	//TODO: Check in nodes
    	String msg = "Checked in with UpdateAssetGUI. Removed:\n\t";
    	for(String asset: oldRef)
    		msg+= (asset + " ");

    	msg+="\nAdded:\n\t";
    	for(String asset: newRef)
    		msg+= (asset + " ");

    	mclient.checkIn(w.user, w.view,shot, msg, VersionID.Level.Major);
    }*/

  } // end processShots
예제 #2
0
    /**
     * Phase in which parameter values should be extracted from parameters and checked for
     * consistency and applicability.
     */
    @Override
    public void validatePhase() throws PipelineException {
      /* sets up the built-in parameters common to all builders */
      validateBuiltInParams();

      /* setup the StudioDefinitions version of the UtilContext */
      pStudioDefs.setContext(pContext);

      /* lookup the source images node */
      String sourceNodeName = null;
      VersionID sourceVersionID = null;
      {
        Path spath = (Path) getParamValue(aSourceNode);
        if (spath == null) throw new PipelineException("No " + aSourceNode + " was specified!");
        sourceNodeName = spath.toString();
        pSourcePrefix = spath.getName();

        String sversion = (String) getParamValue(aSourceVersion);
        if (sversion == null)
          throw new PipelineException("No " + aSourceVersion + " was specified!");

        try {
          sourceVersionID = new VersionID(sversion);
        } catch (Exception ex) {
          throw new PipelineException(
              "The value supplied for the "
                  + aSourceVersion
                  + " parameter "
                  + "("
                  + sversion
                  + ") is not a legal node revision number!\n\n"
                  + ex.getMessage());
        }

        try {
          pSourceVersion = pClient.getCheckedInVersion(sourceNodeName, sourceVersionID);
        } catch (PipelineException ex) {
          throw new PipelineException(
              "The source images node ("
                  + sourceNodeName
                  + " v"
                  + sourceVersionID
                  + ") "
                  + "does not exist!");
        }
      }

      /* set namer/builder parameters based on the annotations on the source images node */
      {
        boolean validated = false;
        String projName = null;
        String taskName = null;
        String taskType = null;
        TreeMap<String, BaseAnnotation> annotations = pClient.getAnnotations(sourceNodeName);
        TreeSet<String> otherPurposes = new TreeSet<String>();
        for (String aname : annotations.keySet()) {
          if (aname.equals("Task") || aname.startsWith("AltTask")) {
            BaseAnnotation annot = annotations.get(aname);
            String purpose = lookupPurpose(sourceNodeName, aname, annot);
            if (purpose == null) {
              otherPurposes.add("<UNKNWON>");
            } else if (purpose.equals(aFocus)
                || purpose.equals(aEdit)
                || purpose.equals(aProduct)) {
              projName = lookupProjectName(sourceNodeName, aname, annot);
              taskName = lookupTaskName(sourceNodeName, aname, annot);
              taskType = lookupTaskType(sourceNodeName, aname, annot);
              validated = true;
              break;
            } else {
              otherPurposes.add(purpose);
            }
          }
        }

        if (!validated) {
          StringBuilder buf = new StringBuilder();
          buf.append(
              "Unable to find an valid "
                  + aEdit
                  + ", "
                  + aFocus
                  + " or "
                  + aProduct
                  + " "
                  + "task annotation for the source images node ("
                  + sourceNodeName
                  + " v"
                  + sourceVersionID
                  + ")!");

          if (!otherPurposes.isEmpty()) {
            buf.append(
                "\n\nHowever, there were task annotations on the source images node for "
                    + "the following unsupported purposes:");
            for (String purpose : otherPurposes) buf.append(" " + purpose);
          }

          throw new PipelineException(buf.toString());
        }

        if (taskName.length() != 5)
          throw new PipelineException(
              "The "
                  + aTaskName
                  + " ("
                  + taskName
                  + ") of the source images "
                  + "node ("
                  + sourceNodeName
                  + " v"
                  + sourceVersionID
                  + ") did not conform to "
                  + "the 2-letter sequence name followed by 3-digit shot number format!");
        pProjectName = projName;
        pSeqName = taskName.substring(0, 2);
        pShotName = taskName.substring(2, 5);

        try {
          pTaskType = TaskType.valueOf(TaskType.class, taskType);
        } catch (IllegalArgumentException ex) {
          throw new PipelineException(
              "The "
                  + DeliverNamer.aTaskType
                  + " ("
                  + taskType
                  + ") of the source images "
                  + "node ("
                  + sourceNodeName
                  + " v"
                  + sourceVersionID
                  + ") was an unknown type "
                  + "by this builder!");
        }
      }

      /* generate a temporary working area where the approval process will take place
      and change the util context to use it instead for all future operations */
      {
        String tempView =
            ("QtDeliver" + "-" + pProjectName + "-" + pSeqName + pShotName + "-" + pSourcePrefix);
        tempView = tempView.replaceAll(" ", "_");

        setContext(new UtilContext(pContext.getAuthor(), tempView, pContext.getToolset()));
      }

      /* turn on the DoAnnotations flag for the StageInformation shared by all
      of the Stages created by this builder since we always want task annotations */
      getStageInformation().setDoAnnotations(true);

      /* initialize internal Project namer */
      {
        pProjectNamer.setParamValue(new ParamMapping(StudioDefinitions.aProjectName), pProjectName);
        pProjectNamer.generateNames();
      }
    }