/**
   * Check that the user has properly selected a target node for this tool
   *
   * <p>
   *
   * @return The phase progress message or <CODE>null</CODE> to abort early.
   * @throws PipelineException If unable to validate the given user input.
   */
  public synchronized String collectPhaseInput() throws PipelineException {
    if ((pPrimary == null) || (pSelected.size() != 1))
      throw new PipelineException("Please selected one node only.");

    // folder = nPath.getParent();
    // assetName = nPath.getName();
    Path nPath = new Path(pPrimary);
    nPath = nPath.getParentPath().getParentPath();

    if (!nPath.toString().matches(assetPattern))
      throw new PipelineException(
          "This tool only works on assets." + nPath.toString() + " " + nPath.toOsString());

    // if(!pPrimary.matches(matPattern))
    // throw new PipelineException("This tool will only work on a lgt node!");

    File errFile;
    try {
      errFile = File.createTempFile("MaterialsCheckOut", ".err", PackageInfo.sTempPath.toFile());
      err = new PrintWriter(errFile);
      FileCleaner.add(errFile);
    } catch (IOException e) {
      e.printStackTrace();
    }

    NodeStatus status = pSelected.get(pPrimary);
    NodeID nodeID = status.getNodeID();
    pUser = nodeID.getAuthor();
    pView = nodeID.getView();

    OverallNodeState state = status.getHeavyDetails().getOverallNodeState();
    JToolDialog tool = new JToolDialog("MaterialsCheckOut", new JPanel(), "Continue");
    if (!state.equals(OverallNodeState.Identical)) {
      JConfirmDialog dialog =
          new JConfirmDialog(
              tool,
              "This node is different from the checked in node. Do you want to continue with this check out?");
      dialog.setVisible(true);
      if (!dialog.wasConfirmed()) {
        return null;
      } // end if
    } // end if

    return "...Sing Hallelujah!";
  }
Esempio n. 2
0
    @SuppressWarnings("unchecked")
    @Override
    public void validatePhase() throws PipelineException {
      /* the slate and format Nuke script nodes */
      String slatePrefix = null;
      {
        String script = getStringParamValue(new ParamMapping(aSlateScript), false);
        Path path = new Path(pProjectNamer.getSlateNukeScriptsParentPath(), script);
        pSlateNodeName = path.toString();
        slatePrefix = path.getName();
        pRequiredNodeNames.add(pSlateNodeName);
      }

      String formatPrefix = null;
      {
        String script = getStringParamValue(new ParamMapping(aFormatScript), false);
        Path path = new Path(pProjectNamer.getFormatNukeScriptsParentPath(), script);
        pFormatNodeName = path.toString();
        formatPrefix = path.getName();
        pRequiredNodeNames.add(pFormatNodeName);
      }

      /* the final QuickTime codec settings */
      String codecPrefix = null;
      {
        String settings = getStringParamValue(new ParamMapping(aCodecSettings), false);
        Path path = new Path(pProjectNamer.getQtCodecSettingsParentPath(), settings);
        pCodecNodeName = path.toString();
        codecPrefix = path.getName();
        pRequiredNodeNames.add(pCodecNodeName);
      }

      /* lookup the rest of the parameters */
      pDeliveryType = getStringParamValue(new ParamMapping(aDeliveryType));
      pDeliverable = getStringParamValue(new ParamMapping(DeliverNamer.aDeliverable), false);
      pClientVersion = getStringParamValue(new ParamMapping(aClientVersion));
      pClientShotName = getStringParamValue(new ParamMapping(aClientShotName));
      pLensInfo = getStringParamValue(new ParamMapping(aLensInfo), false);
      pTakeInfo = getStringParamValue(new ParamMapping(aTakeInfo), false);
      pNotes = getStringParamValue(new ParamMapping(aNotes));
      pSlateHold = getIntegerParamValue(new ParamMapping(aSlateHold), new Range<Integer>(0, null));

      /* compute the full frame range with slate holds added */
      FrameRange range = pSourceVersion.getPrimarySequence().getFrameRange();
      if (range.getBy() != 1)
        throw new PipelineException(
            "The source images node ("
                + pSourceVersion.getName()
                + " v"
                + pSourceVersion.getVersionID()
                + ") must have a frame step increment of (1)!");
      pFrameRange = new FrameRange(range.getStart(), range.getEnd() + pSlateHold, 1);

      /* initialize internal Deliver (Shot) namer */
      {
        pDeliverNamer = new DeliverNamer(pClient, pQueue, getBuilderInformation(), pStudioDefs);
        pShotNamer = pDeliverNamer;

        pDeliverNamer.setParamValue(new ParamMapping(StudioDefinitions.aProjectName), pProjectName);
        pDeliverNamer.setParamValue(new ParamMapping(StudioDefinitions.aSequenceName), pSeqName);
        pDeliverNamer.setParamValue(new ParamMapping(StudioDefinitions.aShotName), pShotName);
        pDeliverNamer.setParamValue(new ParamMapping(DeliverNamer.aDeliverable), pDeliverable);
        pDeliverNamer.setParamValue(new ParamMapping(DeliverNamer.aTaskType), pTaskType.toString());
        pDeliverNamer.setParamValue(new ParamMapping(DeliverNamer.aSlatePrefix), slatePrefix);
        pDeliverNamer.setParamValue(new ParamMapping(DeliverNamer.aFormatPrefix), formatPrefix);
        pDeliverNamer.setParamValue(new ParamMapping(DeliverNamer.aCodecPrefix), codecPrefix);

        pDeliverNamer.generateNames();
      }
    }
Esempio n. 3
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();
      }
    }
Esempio n. 4
0
  private boolean dylanate(
      MasterMgrClient mclient,
      String switchName,
      DoubleMap<String, String, TreeSet<VersionID>> plugs)
      throws PipelineException {
    err.println("\nProcessing: " + switchName);
    String animName = null;

    {
      NodeMod switchMod = null;
      try {
        switchMod = mclient.getWorkingVersion(pUser, pView, switchName);
      } catch (PipelineException e) {
        mclient.checkOut(pUser, pView, switchName, null, keep, pFroz);
        switchMod = mclient.getWorkingVersion(pUser, pView, switchName);
      }

      TreeSet<String> switchSrcs = new TreeSet<String>(switchMod.getSourceNames());

      for (String src : switchSrcs) {
        if (src.matches(animPattern)) {
          animName = src;
          err.println("Found anim node: " + src);
          mclient.checkOut(pUser, pView, src, null, over, frozU);
          continue;
        } // end if

        mclient.checkOut(pUser, pView, src, null, over, frozU);

        LinkMod lMod = switchMod.getSource(src);
        LinkPolicy rel = lMod.getPolicy();
        System.err.println(src + ": " + rel);
        if (!rel.equals(REF)) {
          System.err.println("umm");
          lMod.setPolicy(REF);
          switchMod.setSource(lMod);
          mclient.modifyProperties(pUser, pView, switchMod);
        }
      } // end for

      err.println("anim node: " + animName);

      mclient.modifyProperties(pUser, pView, switchMod);

      if (animName == null)
        throw new PipelineException("This switch node does not have an associated anim node");
    }
    err.println("Checked out the anim and switch nodes");

    String actionName = null;
    VersionID ttVer = null;
    boolean toCache = false;

    /*change the action setting on the Switch node*/
    {
      NodeMod switchMod = mclient.getWorkingVersion(pUser, pView, switchName);

      Path p = new Path(switchName);
      Path syfRoot = new Path(p.getParentPath().getParentPath(), "syf");
      System.err.println("Going to look for caches in: " + syfRoot);
      ArrayList<String> syfDirs = getChildrenDirs(mclient, syfRoot.toString());

      for (String dir : syfDirs) {
        System.err.println(dir);
        Path dPath = new Path(syfRoot, dir);
        ArrayList<String> simDir = getChildrenNodes(mclient, dPath.toString());
        for (String pCache : simDir) {
          Path cPath = new Path(dPath, pCache);
          if (cPath.toString().matches(cltPattern)) {
            System.err.println("\t" + cPath.toString());
            try {
              mclient.checkOut(pUser, pView, cPath.toString(), null, over, froz);
              mclient.lock(pUser, pView, cPath.toString(), null);
              mclient.link(pUser, pView, switchMod.getName(), cPath.toString(), DEP, LINKALL, null);
            } catch (PipelineException e) {
              e.printStackTrace();
            }
            toCache = true;
          }
        }
      }

      {
        BaseAction action = switchMod.getAction();
        if (!switchMod.getToolset().equals(pToolset)) {
          switchMod.setToolset(pToolset);
          mclient.modifyProperties(pUser, pView, switchMod);
        }

        if (!toCache) {
          actionName = modRep;
        } else {
          actionName = modRep + "Syflex";
        }
        ttVer = plugs.get("SCEA", actionName).last();

        if ((action == null)
            || (!action.getName().equals(actionName))
            || (!action.getVersionID().equals(ttVer))) {
          System.err.println(
              "Action name is incorrect - the switch node "
                  + switchName
                  + " doesn't have a "
                  + actionName
                  + "Action");

          action = plug.newAction(actionName, ttVer, "SCEA");
          action.setSingleParamValue("Source", animName);
          action.setSingleParamValue("Response", "Ignore");
          if (toCache) action.setSingleParamValue(aApplyCache, true);
          switchMod.setAction(action);
          mclient.modifyProperties(pUser, pView, switchMod);
        } else {
          if (!action.getSingleParamValue("Response").equals("Ignore")) {
            //						action = plug.newAction(actionName, ttVer, "SCEA");
            //						action.setSingleParamValue("Source", animName);
            action.setSingleParamValue("Response", "Ignore");
            //						if(toCache)
            //						action.setSingleParamValue(aApplyCache, true);
            switchMod.setAction(action);
            mclient.modifyProperties(pUser, pView, switchMod);
          } // end if
        } // end else
      }
    }

    {
      /*-check out and lock the animation sources-*/
      NodeMod animMod = mclient.getWorkingVersion(pUser, pView, animName);
      Set<String> animSrcs = animMod.getSourceNames();
      for (String src : animSrcs) {
        if (src.matches(loresPattern)) {
          pLoresSrcs.add(src);
          err.println("Adding lores src " + src);
        }
        mclient.checkOut(pUser, pView, src, null, keep, pFroz);
      } // end for
      err.println("lores:" + pLoresSrcs);
    }

    /*-sync the animation assets with the switch assets.*/
    // also remove unnecessary hires models
    {
      NodeMod switchMod = mclient.getWorkingVersion(pUser, pView, switchName);
      for (String src : switchMod.getSourceNames()) {
        if (src.matches(hiresPattern)) {
          err.println("Found hires source " + src);
          if (pLoresSrcs.contains(src + "_lr")) {
            pHiresSrcs.add(src);
            err.println("The hires source matched the anim node.");
          } else {
            err.println("Gotta remove " + src);
          } // end else
        } // end if
      } // end for
    }

    // add necessary hires models
    for (String lores : pLoresSrcs) {
      String hr = lores.replace("_lr", "");
      err.println("Looking at lores source " + lores + " which matches " + hr);
      if (!pHiresSrcs.contains(hr)) {
        err.println("Gotta add " + hr + " to " + switchName);
        pHiresSrcs.add(hr);
      }
    }

    {
      NodeMod switchMod = mclient.getWorkingVersion(pUser, pView, switchName);
      TreeSet<String> switchSrcs = new TreeSet<String>(switchMod.getSourceNames());
      err.println("Final hiRes list:" + pHiresSrcs + "\n");
      err.println("switch now has:\n\t" + switchSrcs + "\n");
      err.println("Looking for things to add.");
      for (String src : pHiresSrcs) {
        if ((src.matches(hiresPattern) && (!switchSrcs.contains(src)))) {
          err.print("Linking ");
          mclient.checkOut(pUser, pView, src, null, over, frozU);
          mclient.link(pUser, pView, pPrimary, src, REF, LINKALL, null);
          switchSrcs.add(src);
        }
        err.println("src from hiRes list: " + src);
      }
    }

    {
      NodeMod switchMod = mclient.getWorkingVersion(pUser, pView, switchName);
      TreeSet<String> switchSrcs = new TreeSet<String>(switchMod.getSourceNames());
      err.println("switch now has:\n\t" + switchSrcs + "\n");
      for (String src : switchSrcs) {
        if ((src.matches(hiresPattern) && (!pHiresSrcs.contains(src)))) {
          err.print("Unlinking ");
          mclient.unlink(pUser, pView, pPrimary, src);
        }
        err.println("src from switch node list: " + src);
      }
    }

    /*queue the switch node*/
    mclient.submitJobs(pUser, pView, switchName, null);

    return false;
  }