/// /// <summary> * gets the subscription query for a given messagetype or creates one if not yet there note that newly created query /// * do not contain a subscription /// * </summary> /// * <param name="queryType"> </param> /// * <returns> the appropriate query </returns> /// public virtual JDFQuery getCreateJMFQuery(EnumType queryType) { JDFQuery q = null; VElement v = getChildElementVector(ElementName.JMF, null); if (v != null) { int siz = v.Count; for (int i = 0; i < siz; i++) { JDFJMF jmf = (JDFJMF)v[i]; q = (JDFQuery)jmf.getMessageElement(EnumFamily.Query, queryType, 0); if (q != null) { break; } } } if (q == null) { q = appendJMF().appendQuery(queryType); } return(q); }
public static void submitMimeToHDM(JDFNode n) { // build SubmitQueueEntry JDFDoc docJMF = new JDFDoc("JMF"); JDFJMF jmf = docJMF.getJMFRoot(); JDFCommand com = (JDFCommand)jmf.appendMessageElement(JDFMessage.EnumFamily.Command, JDFMessage.EnumType.SubmitQueueEntry); com.appendQueueSubmissionParams().setURL("dummy"); System.Net.Mail.AttachmentCollection mp = MimeUtil.buildMimePackage(docJMF, n.getOwnerDocument_JDFElement(), true); try { MIMEDetails md = new MIMEDetails(); md.transferEncoding = UrlUtil.BASE64; md.httpDetails.chunkSize = -1; HttpWebRequest response = MimeUtil.writeToURL(mp, "http://192.168.40.71:8889/jmfportal", md); // Java to C# Converstion - What is the ResponseCode for HttpWebRequest? //Assert.AreEqual(200, response.GetResponse().getResponseCode()); MimeUtil.writeToURL(mp, UrlUtil.fileToUrl(new FileInfo("C:\\data\\test.mim"), false), md); } catch (Exception e) { Assert.Fail(e.Message); // fail on exception } }
public virtual void testBuildMimePackageDocJMF() { JDFDoc docJMF = new JDFDoc("JMF"); docJMF.setOriginalFileName("JMF.jmf"); JDFJMF jmf = docJMF.getJMFRoot(); JDFCommand com = (JDFCommand)jmf.appendMessageElement(JDFMessage.EnumFamily.Command, JDFMessage.EnumType.SubmitQueueEntry); com.appendQueueSubmissionParams().setURL("TheJDF"); JDFDoc doc = new JDFDoc("JDF"); doc.setOriginalFileName("JDF.jdf"); JDFNode n = doc.getJDFRoot(); n.setType(EnumType.ColorSpaceConversion); JDFColorSpaceConversionParams cscp = (JDFColorSpaceConversionParams)n.addResource(ElementName.COLORSPACECONVERSIONPARAMS, null, EnumUsage.Input, null, null, null, null); JDFFileSpec fs0 = cscp.appendFinalTargetDevice(); fs0.setURL(StringUtil.uncToUrl(sm_dirTestData + "test.icc", true)); JDFRunList rl = (JDFRunList)n.addResource(ElementName.RUNLIST, null, EnumUsage.Input, null, null, null, null); rl.addPDF(StringUtil.uncToUrl(sm_dirTestData + "url1.pdf", false), 0, -1); for (int i = 0; i < 100; i++) { rl.addPDF(StringUtil.uncToUrl(sm_dirTestData + "url?.pdf", false), 0, -1); } AttachmentCollection m = MimeUtil.buildMimePackage(docJMF, doc, true); MimeUtil.writeToFile(m, sm_dirTestDataTemp + "testMimePackageDoc.mjm", null); }
/// /// * <param name="amounts"> </param> /// * <param name="jmfRes"> </param> /// private void generateResourceSignal(AmountBag[] amounts, JDFJMF jmfRes) { if (amounts != null) { VElement vResResourceInfo = getVResLink(amounts, 3); JDFSignal sig = jmfRes.appendSignal(EnumType.Resource); JDFResourceQuParams rqp = sig.appendResourceQuParams(); rqp.setJDF(m_Node); rqp.setExact(false); bool bAllExact = true; for (int i = 0; i < vResResourceInfo.Count; i++) { JDFResourceInfo ri = sig.appendResourceInfo(); JDFResourceLink rl = (JDFResourceLink)vResResourceInfo[i]; LinkAmount la = getLinkAmount(rl.getrRef()); bool bExact = la.bCopyResInfo; bAllExact = bAllExact && bExact; rqp.setExact(bExact); ri.setLink(rl, rqp); } rqp.setExact(bAllExact); } }
public virtual void testSetPhaseJMF() { JDFDoc docJMF = new JDFDoc("JMF"); JDFJMF jmf = docJMF.getJMFRoot(); JDFSignal sig = jmf.appendSignal(EnumType.Status); JDFDeviceInfo di = sig.appendDeviceInfo(); di.appendEmployee().setPersonalID("p1"); JDFJobPhase phase = di.appendJobPhase(); phase.setPhaseStartTime(new JDFDate()); phase.setStatus(EnumNodeStatus.Setup); phase.setJobID(jdfRoot.getJobID(true)); phase.setJobPartID(jdfRoot.getJobPartID(true)); VElement el = myAuditPool.setPhase(jmf); Assert.IsNotNull(el); Assert.AreEqual(1, myAuditPool.getChildElementVector(ElementName.PHASETIME, null, null, true, 0, true).Count); Assert.IsNotNull(((JDFPhaseTime)myAuditPool.getAudit(0, EnumAuditType.PhaseTime, null, null)).getEmployee(0)); Assert.AreEqual(el, myAuditPool.getChildElementVector(ElementName.PHASETIME, null, null, true, 0, true)); el = myAuditPool.setPhase(jmf); Assert.IsNotNull(el); Assert.AreEqual(1, myAuditPool.getChildElementVector(ElementName.PHASETIME, null, null, true, 0, true).Count); Assert.AreEqual(el, myAuditPool.getChildElementVector(ElementName.PHASETIME, null, null, true, 0, true)); phase.setStatus(EnumNodeStatus.Aborted); el = myAuditPool.setPhase(jmf); Assert.IsNotNull(el); Assert.AreEqual(2, myAuditPool.getChildElementVector(ElementName.PHASETIME, null, null, true, 0, true).Count); Assert.AreEqual(el[0], myAuditPool.getChildElementVector(ElementName.PHASETIME, null, null, true, 0, true)[1]); }
// (non-Javadoc) // * @see org.cip4.jdflib.util.HotFolderListener#hotFile(java.io.File) // public virtual void hotFile(FileInfo hotFile) { FileInfo storedFile = FileUtil.moveFileToDir(hotFile, storageDir); if (storedFile == null) { return; // not good } string stringURL = UrlUtil.fileToUrl(storedFile, false); JDFDoc jmfDoc = new JDFDoc("JMF"); JDFJMF jmfRoot = jmfDoc.getJMFRoot(); JDFCommand newCommand = (JDFCommand)jmfRoot.copyElement(queueCommand, null); newCommand.removeAttribute(AttributeName.ID); newCommand.appendAnchor(null); EnumType cType = newCommand.getEnumType(); JDFDoc jdfDoc = JDFDoc.parseFile(storedFile.FullName); JDFNode jdfRoot = jdfDoc == null ? null : jdfDoc.getJDFRoot(); if (EnumType.ReturnQueueEntry.Equals(cType)) { extractReturnParams(stringURL, newCommand, jdfRoot); } else if (EnumType.SubmitQueueEntry.Equals(cType)) { extractSubmitParams(stringURL, newCommand, jdfRoot); } qhfl.submitted(jmfRoot); }
/// /// <summary> * return the jmf root of the status jmf that contains all modules, null if no modules are active /// * /// * @return </summary> /// public virtual JDFDoc getStatusResponse() { if (counters.Count == 0) { return(null); } StatusCounter root = counters[0]; JDFDoc d = new JDFDoc("JMF"); JDFJMF jmf = d.getJMFRoot(); jmf.mergeElement(root.getDocJMFPhaseTime().getJMFRoot(), false); JDFDeviceInfo di = jmf.getResponse(0).getDeviceInfo(0); for (int i = 1; i < counters.Count; i++) { StatusCounter counter = counters[i]; JDFDoc docJMFPhaseTime = counter.getDocJMFPhaseTime(); if (docJMFPhaseTime == null) { continue; } JDFDeviceInfo di2 = docJMFPhaseTime.getJMFRoot().getResponse(0).getDeviceInfo(0); VElement phases = di2.getChildElementVector(ElementName.JOBPHASE, null, null, true, -1, false); for (int j = 0; j < phases.Count; j++) { di.copyElement(phases[j], null); } di.setDeviceStatus(getDeviceStatus()); } return(d); }
public virtual void testEvent() { Assert.IsNull(sc.getDocJMFNotification(false)); sc.setEvent("id", "value", "blah blah"); d = sc.getDocJMFNotification(false); JDFDoc d2 = sc.getDocJMFNotification(false); Assert.IsTrue(d.getRoot().isEqual(d2.getRoot())); d = sc.getDocJMFNotification(true); d2 = sc.getDocJMFNotification(false); Assert.IsNull(d2); JDFJMF jmf = d.getJMFRoot(); JDFNotification noti = jmf.getSignal(0).getNotification(); Assert.AreEqual(noti.getJobID(), n.getJobID(true)); Assert.IsNotNull(noti.getEvent()); d.write2File(sm_dirTestDataTemp + "jmfNotification.jmf", 2, false); Assert.IsTrue(jmf.isValid(EnumValidationLevel.Complete)); sc.setEvent("id1", "value", "blah blah"); sc.setEvent("id2", "value", "blah blah blah"); d = sc.getDocJMFNotification(false); jmf = d.getJMFRoot(); Assert.AreEqual(2, jmf.numChildElements(ElementName.SIGNAL,null)); sc.setEvent("id2","value","blah blah blah"); d = sc.getDocJMFNotification(true); jmf = d.getJMFRoot(); Assert.AreEqual(3,jmf.numChildElements(ElementName.SIGNAL,null)); d = sc.getDocJMFNotification(true); Assert.IsNull(d); }
public virtual void teststopStart() { MyListener myListener = new MyListener(); FileInfo file = new FileInfo(theHF + Path.DirectorySeparatorChar.ToString() + "f1.txt"); FileInfo stFile = new FileInfo(theStorage + Path.DirectorySeparatorChar.ToString() + "f1.txt"); SupportClass.FileSupport.CreateNewFile(file); file.Refresh(); Assert.IsTrue(file.Exists); Assert.IsFalse(stFile.Exists); hf = new QueueHotFolder(theHF, theStorage, null, myListener, null); hf.stop(); StatusCounter.sleep(3000); file.Refresh(); Assert.IsTrue(file.Exists); stFile.Refresh(); Assert.IsFalse(stFile.Exists, "FileInfo is still there after stop"); Assert.AreEqual(0, myListener.vJMF.Count); hf.restart(); StatusCounter.sleep(3000); file.Refresh(); Assert.IsFalse(file.Exists, "FileInfo is gone after stop"); stFile.Refresh(); Assert.IsTrue(stFile.Exists); Assert.AreEqual(1, myListener.vJMF.Count); JDFJMF elementAt = (JDFJMF)myListener.vJMF[0]; Assert.AreEqual(JDFMessage.EnumType.SubmitQueueEntry, elementAt.getCommand(0).getEnumType()); Assert.AreEqual(UrlUtil.fileToUrl(stFile, false), elementAt.getCommand(0).getQueueSubmissionParams(0).getURL()); }
/// /// * <param name="icsLevel"> </param> /// protected internal override JDFNodeInfo initNodeInfo() { JDFNodeInfo ni = base.initNodeInfo(); if (theParentNode == null) { JDFEmployee emp = ni.appendEmployee(); emp.setPersonalID("personalID1"); emp.setRoles(new VString("CSR", null)); if (returnURL != null) { ni.setTargetRoute(returnURL); } if (jmfICSLevel >= 1 && misICSLevel >= 2 || misURL != null) { JDFJMF jmf = ni.appendJMF(); jmf.setSenderID("MISGTSender"); JDFQuery q = jmf.appendQuery(EnumType.Status); q.setID(q.getID() + (System.DateTime.Now.Ticks - 621355968000000000) / 10000 % 100000); //ORIGINAL LINE: final JDFStatusQuParams statusQuParams = q.appendStatusQuParams(); JDFStatusQuParams statusQuParams = q.appendStatusQuParams(); statusQuParams.setJobID(theNode.getJobID(true)); statusQuParams.setJobPartID(theNode.getJobPartID(false)); statusQuParams.setJobDetails(EnumJobDetails.Brief); //ORIGINAL LINE: final JDFSubscription subscription = q.appendSubscription(); JDFSubscription subscription = q.appendSubscription(); subscription.setRepeatTime(600); subscription.setURL(misURL == null ? "http://MIS.printer.com/JMFSignal" : misURL); } } return(ni); }
public virtual void testWritePerformance() { long start = JDFDate.ToMillisecs(DateTime.Now); string big = sm_dirTestData + "big.pdf"; string bigger = sm_dirTestDataTemp + "bigger.pdf"; JDFDoc docJMF = new JDFDoc("JMF"); docJMF.setOriginalFileName("JMF.jmf"); JDFJMF jmf = docJMF.getJMFRoot(); JDFCommand com = (JDFCommand)jmf.appendMessageElement(JDFMessage.EnumFamily.Command, JDFMessage.EnumType.SubmitQueueEntry); com.appendQueueSubmissionParams().setURL("TheJDF"); FileInfo fBigger = new FileInfo(bigger); SupportClass.FileSupport.CreateNewFile(fBigger); FileStream fis = new FileStream(big, FileMode.Open); FileStream fos = new FileStream(bigger, FileMode.Create); byte[] b = new byte[10000]; while (true) { int i = fis.Read(b, 0, 10000); if (i <= 0) { break; } for (int j = 0; j < 3; j++) { fos.Write(b, 0, i); } } fis.Close(); fos.Flush(); fos.Close(); JDFDoc doc = new JDFDoc("JDF"); doc.setOriginalFileName("JDF.jdf"); JDFNode n = doc.getJDFRoot(); n.setType(EnumType.Interpreting); JDFRunList rl = (JDFRunList)n.addResource(ElementName.RUNLIST, EnumUsage.Input); rl.addPDF(StringUtil.uncToUrl(bigger, false), 0, -1); long setup = JDFDate.ToMillisecs(DateTime.Now); Console.WriteLine("Setup time: " + (setup - start)); AttachmentCollection m = MimeUtil.buildMimePackage(null, doc, true); long build = JDFDate.ToMillisecs(DateTime.Now); Console.WriteLine("Build time: " + (build - setup)); Assert.IsNotNull(MimeUtil.writeToFile(m, sm_dirTestDataTemp + "performance.mjm", null)); long write = JDFDate.ToMillisecs(DateTime.Now); Console.WriteLine("Write time: " + (write - build)); }
public override void setUp() { base.setUp(); JDFDoc doc = new JDFDoc("JMF"); JDFJMF jmf = doc.getJMFRoot(); JDFResponse resp = (JDFResponse)jmf.appendMessageElement(EnumFamily.Response, JDFMessage.EnumType.KnownDevices); deviceCap = resp.appendDeviceList().appendDeviceInfo().appendDevice().appendDeviceCap(); deviceCap.appendBooleanState("Template"); }
public virtual void testEmptyString() { JDFDoc inMessageDoc = new JDFDoc(ElementName.JMF); JDFJMF jmfIn = inMessageDoc.getJMFRoot(); jmfIn.appendMessageElement(JDFMessage.EnumFamily.Response, null); string s = inMessageDoc.write2String(0); Assert.IsNotNull(s); }
public virtual void testGetExecutableJDF() { string docTest = "MISPrepress_ICS_Minimal.jdf"; string docDevCap = "DevCaps_Product_MISPrepress_ICS_Minimal.jdf"; // parse input file JDFParser p = new JDFParser(); JDFDoc jmfDevCap = p.parseFile(sm_dirTestData + docDevCap); JDFJMF jmfRoot = null; Assert.IsNotNull(jmfDevCap, "Parse of file " + docDevCap + " failed"); jmfRoot = jmfDevCap.getJMFRoot(); Assert.IsNotNull(jmfRoot, "jmfRoot == null Can't start Test"); XMLDoc docOutDevCap = jmfRoot.getOwnerDocument_KElement(); docOutDevCap.write2File(sm_dirTestDataTemp + "_" + docDevCap, 0, true); JDFDoc jdfTest = p.parseFile(sm_dirTestData + docTest); JDFNode jdfRoot = jdfTest.getJDFRoot(); Assert.IsTrue(jdfRoot != null, "jdfRoot is null"); if (jdfRoot != null) { jdfRoot.getOwnerDocument_KElement(); JDFDeviceCap deviceCap = (JDFDeviceCap)jmfRoot.getChildByTagName("DeviceCap", null, 0, null, false, true); EnumFitsValue testlists = EnumFitsValue.Allowed; EnumValidationLevel level = KElement.EnumValidationLevel.Complete; VElement vExecNodes = deviceCap.getExecutableJDF(jdfRoot, testlists, level); if (vExecNodes == null) { Console.WriteLine(docDevCap + ": found No matching JDFNode"); } else { for (int n = 0; n < vExecNodes.Count; n++) { // XMLDoc docExecNodes = ((JDFNode) // vExecNodes.elementAt(n)).getOwnerDocument_KElement(); // docExecNodes.write2File ("temp\\" + "_" + docTest // +"_ExecNode" + (n+1) + // ".jdf", 0); Console.WriteLine(vExecNodes[n]); } } XMLDoc testResult = deviceCap.getBadJDFInfo(jdfRoot, testlists, level); if (testResult != null) { testResult.write2File(sm_dirTestDataTemp + "_BugReport.xml", 0, true); } } }
public virtual void testDeviceCapIsValid() { JDFParser p = new JDFParser(); string docDevCap = "DevCaps_Product_MISPrepress_ICS_Minimal.jdf"; JDFDoc jmfDevCap = p.parseFile(sm_dirTestData + docDevCap); Assert.IsNotNull(jmfDevCap, "Parse of file " + docDevCap + " failed"); JDFJMF jmfRoot = jmfDevCap.getJMFRoot(); Assert.IsNotNull(jmfRoot, "jmfRoot == null Can't start Test"); JDFDeviceCap deviceCap = (JDFDeviceCap)jmfRoot.getChildByTagName("DeviceCap", "", 0, null, false, true); Assert.IsTrue(deviceCap.isValid(KElement.EnumValidationLevel.Incomplete)); }
public virtual void testReprintJMF() { testAuditsImageSetting(); statCounter.setActiveNode(null, null, null); string sheet = vsSheet.stringAt(1); VJDFAttributeMap vmP = new VJDFAttributeMap(); JDFAttributeMap attributeMap = new JDFAttributeMap(EnumPartIDKey.SheetName, sheet); attributeMap.put("SignatureName", "Sig1"); attributeMap.put("Separation", vsCMYK.stringAt(3)); attributeMap.put("Side", "Front"); vmP.Add(attributeMap); statCounter.setActiveNode(n, vmP, vRL); string refXM = rlXMOut.getrRef(); string refMedia = rlMediaIn.getrRef(); statCounter.setTrackWaste(refXM, true); statCounter.setTrackWaste(refMedia, false); statCounter.setActiveNode(n, vmP, vRL); statCounter.setWorkType(EnumWorkType.Rework); statCounter.setPhase(EnumNodeStatus.InProgress, "Imaging", EnumDeviceStatus.Running, null); statCounter.addPhase(refMedia, 1, 0, true); statCounter.addPhase(refXM, 1, 0, true); statCounter.setPhase(EnumNodeStatus.InProgress, "Imaging", EnumDeviceStatus.Running, null); JDFDoc d2 = statCounter.getDocJMFResource(); JDFJMF jmf = d2.getJMFRoot(); jmf.convertResponses(null); VElement vSigs = jmf.getMessageVector(JDFMessage.EnumFamily.Signal, JDFMessage.EnumType.Resource); d2.write2File(sm_dirTestDataTemp + "ImageSetResourceReprint_.jmf", 2, false); JDFDoc dStatusJMF = statCounter.getDocJMFPhaseTime(); jmf = dStatusJMF.getJMFRoot(); jmf.convertResponses(null); for (int i = 0; i < vSigs.Count; i++) { jmf.copyElement(vSigs.item(i), null); } dStatusJMF.write2File(sm_dirTestDataTemp + "ImageSetReprint_.jmf", 2, false); // JDFResourceAudit ra= statCounter.setResourceAudit(refMedia, EnumReason.ProcessResult); // JDFProcessRun pr= statCounter.setProcessResult(EnumNodeStatus.Completed); d.write2File(sm_dirTestDataTemp + "ImageSetAmount_Reprint.jdf", 2, false); }
/// /// <summary> * Get all JMF from the current element /// * </summary> /// * <returns> Collection<JDFJMF> </returns> /// public virtual ICollection <JDFJMF> getAllJMF() { List <JDFJMF> v = new List <JDFJMF>(); JDFJMF kElem = (JDFJMF)getFirstChildElement(ElementName.JMF, null); while (kElem != null) { v.Add(kElem); kElem = (JDFJMF)kElem.getNextSiblingElement(ElementName.JMF, null); } return(v); }
public virtual void testAuditsImageSetting() { for (int i = 0; i < vsSheet.Count; i++) { string sheet = vsSheet.stringAt(i); VJDFAttributeMap vmP = new VJDFAttributeMap(); JDFAttributeMap attributeMap = new JDFAttributeMap(EnumPartIDKey.SheetName, sheet); attributeMap.put("SignatureName", "Sig1"); vmP.Add(attributeMap); statCounter.setActiveNode(n, vmP, vRL); string refXM = rlXMOut.getrRef(); string refMedia = rlMediaIn.getrRef(); statCounter.setTrackWaste(refXM, true); statCounter.setTrackWaste(refMedia, false); statCounter.setPhase(EnumNodeStatus.Stopped, "PowerOn", EnumDeviceStatus.Stopped, "PowerOn"); statCounter.setPhase(EnumNodeStatus.InProgress, "Imaging", EnumDeviceStatus.Running, null); statCounter.addPhase(refMedia, 5, 0, true); statCounter.addPhase(refXM, 5, 0, true); statCounter.setPhase(EnumNodeStatus.InProgress, "Imaging", EnumDeviceStatus.Running, null); // JDFResourceAudit ra= statCounter.setResourceAudit(refMedia, EnumReason.ProcessResult); JDFProcessRun pr = statCounter.setProcessResult(EnumNodeStatus.Completed); pr.setDescriptiveName("we even have the utterly useless ProcessRun"); } d.write2File(sm_dirTestDataTemp + "ImageSetAmount_.jdf", 2, false); JDFDoc d2 = statCounter.getDocJMFResource(); JDFJMF jmf = d2.getJMFRoot(); jmf.convertResponses(null); JDFSignal sig = jmf.appendSignal(org.cip4.jdflib.jmf.JDFMessage.EnumType.Notification); JDFNotification not = sig.appendNotification(); not.setXPathAttribute("MileStone/@MileStoneType", "PrepressCompleted"); not.setXPathAttribute("MileStone/@Amount", "5"); d2.write2File(sm_dirTestDataTemp + "ImageSetAmount_.jmf", 2, false); JDFDoc dStatusJMF = statCounter.getDocJMFPhaseTime(); jmf = dStatusJMF.getJMFRoot(); jmf.convertResponses(null); dStatusJMF.write2File(sm_dirTestDataTemp + "ImageSetPhaseTime_.jmf", 2, false); }
public virtual void testGetJMFSubmission() { JDFDoc d1 = new JDFDoc("JMF"); d1.setOriginalFileName("JMF.jmf"); JDFJMF jmf = d1.getJMFRoot(); jmf.setDeviceID("gr?n?"); JDFCommand com = (JDFCommand)jmf.appendMessageElement(JDFMessage.EnumFamily.Command, JDFMessage.EnumType.SubmitQueueEntry); com.appendQueueSubmissionParams().setURL("TheJDF"); JDFDoc doc = new JDFDoc("JDF"); doc.setOriginalFileName("JDF.jdf"); JDFNode n = doc.getJDFRoot(); n.setType(EnumType.ColorSpaceConversion); JDFColorSpaceConversionParams cscp = (JDFColorSpaceConversionParams)n.addResource(ElementName.COLORSPACECONVERSIONPARAMS, null, EnumUsage.Input, null, null, null, null); JDFFileSpec fs0 = cscp.appendFinalTargetDevice(); fs0.setURL(StringUtil.uncToUrl(sm_dirTestData + "test.icc", true)); JDFRunList rl = (JDFRunList)n.addResource(ElementName.RUNLIST, null, EnumUsage.Input, null, null, null, null); rl.addPDF(StringUtil.uncToUrl(sm_dirTestData + "url1.pdf", false), 0, -1); for (int i = 0; i < 100; i++) { rl.addPDF("gr?n?" + i + ".pdf", 0, -1); } AttachmentCollection m = MimeUtil.buildMimePackage(d1, doc, true); JDFDoc[] d2 = MimeUtil.GetJMFSubmission(m); Assert.IsNotNull(d2); Assert.AreEqual("cid:JDF.jdf", d2[0].getJMFRoot().getCommand(0).getQueueSubmissionParams(0).getURL()); Assert.AreEqual(EnumType.ColorSpaceConversion, d2[1].getJDFRoot().getEnumType()); // now serialize to file and reread - should still work MimeUtil.writeToFile(m, sm_dirTestDataTemp + "test2.mjm", null); AttachmentCollection m2 = MimeUtil.GetMultiPart(sm_dirTestDataTemp + "test2.mjm"); Assert.IsNotNull(m2); d2 = MimeUtil.GetJMFSubmission(m); Assert.IsNotNull(d2); Assert.AreEqual("cid:JDF.jdf", d2[0].getJMFRoot().getCommand(0).getQueueSubmissionParams(0).getURL()); Assert.AreEqual(EnumType.ColorSpaceConversion, d2[1].getJDFRoot().getEnumType()); }
private readonly JDFCommand queueCommand; // the jdf command template that is used to generate a new message for each dropped file /// /// <summary> * /// * constructor for a simple queue based hotfolder watcher that is automagically started in its own thread /// * </summary> /// * <param name="_hotFolderDir"> the hot folder directory to watch </param> /// * <param name="_storageDir"> the storage directory wher hot files are moved to </param> /// * <param name="ext"> the file extensions that are moved - if null no filtering </param> /// * <param name="hfListener"> callback that receives the generated JMF - the location of the stored file will be found in the standard command parameters </param> /// * <param name="_queueCommand"> the jmf template that will be used to generate a new message, null creates an empty SubmitQueueEntry template </param> /// public QueueHotFolder(DirectoryInfo _hotFolderDir, DirectoryInfo _storageDir, string ext, QueueHotFolderListener hfListener, JDFJMF _queueCommand) { JDFJMF _queueCommandLocal = _queueCommand; storageDir = _storageDir; if (!storageDir.Exists) { storageDir.Create(); // just in case } qhfl = hfListener; if (_queueCommandLocal == null) { _queueCommandLocal = JDFJMF.createJMF(JDFMessage.EnumFamily.Command, JDFMessage.EnumType.SubmitQueueEntry); } queueCommand = _queueCommandLocal.getCommand(0); hf = new HotFolder(_hotFolderDir, ext, this); }
/// /// <summary> * finds all status messages in a jmf and fills the phaseTime with the appropriate data /// * </summary> /// * <param name="jmf"> </param> /// * <returns> vector the vector of all modified phasetime elements </returns> /// public virtual VElement setPhase(JDFJMF jmf) { VElement vMessages = jmf.getMessageVector(null, EnumType.Status); if (vMessages == null) { return(null); } VElement vRet = new VElement(); for (int i = 0; i < vMessages.Count; i++) { JDFMessage status = (JDFMessage)vMessages[i]; VElement devInfos = status.getChildElementVector(ElementName.DEVICEINFO, null, null, true, 0, true); for (int j = 0; j < devInfos.Count; j++) { JDFDeviceInfo devInfo = (JDFDeviceInfo)devInfos[j]; VElement phases = devInfo.getChildElementVector(ElementName.JOBPHASE, null, null, true, 0, true); for (int k = 0; k < phases.Count; k++) { JDFJobPhase phase = (JDFJobPhase)phases[k]; string jobID = phase.getJobID(); if (!jobID.Equals(getParentJDF().getJobID(true))) { continue; } string jobPartID = phase.getJobPartID(); if (!jobPartID.Equals(getParentJDF().getJobPartID(true))) { continue; } JDFPhaseTime pt = setPhase(phase.getStatus(), phase.getStatusDetails(), phase.getPartMapVector(), devInfo.getChildElementVector(ElementName.EMPLOYEE, null)); pt.copyElement(phase.getMISDetails(), null); pt.setEnd(jmf.getTimeStamp()); pt.setStart(phase.getPhaseStartTime()); vRet.Add(pt); } } } vRet.unify(); return(vRet.Count == 0 ? null : vRet); }
public virtual void testGetLinkRootJMF() { JDFDoc d = new JDFDoc("JMF"); JDFJMF jmf = d.getJMFRoot(); jmf.setSenderID("Elvis"); JDFCommand c = jmf.appendCommand(); c.setType("PipePull"); JDFPipeParams pp = c.appendPipeParams(); pp.setAttribute(AttributeName.PIPEID, "foo", null); JDFRunList ruli = (JDFRunList)pp.appendResource(ElementName.RUNLIST); JDFResourceLink rl = pp.appendResourceLink("RunListLink", true); rl.setrRef(ruli.getID()); Assert.IsTrue(jmf.isValid(EnumValidationLevel.Complete), "valid param"); Assert.AreEqual(rl.getTarget(), ruli); }
public virtual void testGetMessageServiceForJMFType() { JDFMessage m = JDFJMF.createJMF(JDFMessage.EnumFamily.Acknowledge, EnumType.KnownDevices).getMessageElement(null, null, 0); JDFResponse resp = JDFJMF.createJMF(JDFMessage.EnumFamily.Response, EnumType.KnownMessages).getResponse(0); JDFMessageService ms = resp.appendMessageService(); ms.setType(EnumType.AbortQueueEntry); ms.setAcknowledge(true); Assert.IsNull(JDFDeviceCap.getMessageServiceForJMFType(m, resp), "wrong type"); JDFMessageService ms2 = resp.appendMessageService(); ms2.setType(EnumType.KnownDevices); ms2.setQuery(true); Assert.IsNull(JDFDeviceCap.getMessageServiceForJMFType(m, resp), "wrong type"); JDFMessageService ms3 = resp.appendMessageService(); ms3.setType(EnumType.KnownDevices); ms3.setAcknowledge(true); Assert.AreEqual(ms3, JDFDeviceCap.getMessageServiceForJMFType(m, resp), "family and type match"); }
public virtual void testDefaultVersion() { JDFDoc doc = new JDFDoc("JDF"); JDFNode n = doc.getJDFRoot(); Assert.AreEqual(n.getVersion(true), EnumVersion.Version_1_3); JDFElement.setDefaultJDFVersion(EnumVersion.Version_1_2); n.setType("ProcessGroup", true); n = n.addJDFNode("Combined"); Assert.AreEqual(EnumVersion.Version_1_3, n.getVersion(true)); doc = new JDFDoc("JDF"); n = doc.getJDFRoot(); Assert.AreEqual(EnumVersion.Version_1_2, n.getVersion(true)); n.setType("ProcessGroup", true); n = n.addJDFNode("Combined"); Assert.AreEqual(EnumVersion.Version_1_2, n.getVersion(true)); doc = new JDFDoc("JMF"); JDFJMF jmf = doc.getJMFRoot(); Assert.AreEqual(EnumVersion.Version_1_2, jmf.getVersion(true)); }
public virtual void testPerfectingJMF() { JDFElement.setLongID(false); JDFJMF jmfStatus = JDFJMF.createJMF(EnumFamily.Signal, EnumType.Status); jmfStatus.setSenderID("thePress"); JDFSignal sig = jmfStatus.getSignal(0); JDFDeviceInfo di = sig.appendDeviceInfo(); di.setDeviceStatus(EnumDeviceStatus.Running); JDFJobPhase jp = di.appendJobPhase(); jp.setJobID("jobID"); jp.setJobPartID("jobPartID"); jp.setStatus(EnumNodeStatus.InProgress); JDFModuleStatus ms = jp.appendModuleStatus(); ms.setModuleID("ID_Perfecting_1"); ms.setModuleType("PerfectingModule"); ms.setDeviceStatus(EnumDeviceStatus.Idle); ms = jp.appendModuleStatus(); ms.setModuleType("PrintModule"); ms.setDeviceStatus(EnumDeviceStatus.Running); ms.setModuleIndex(new JDFIntegerRangeList("0 1 3 4")); ms = jp.appendModuleStatus(); ms.setModuleType("PrintModule"); ms.setDeviceStatus(EnumDeviceStatus.Idle); ms.setModuleIndex(new JDFIntegerRangeList("2")); jmfStatus.getOwnerDocument_JDFElement().write2File(sm_dirTestDataTemp + "StatusPerfecting.jmf", 2, false); Assert.IsTrue(jmfStatus.isValid(EnumValidationLevel.Complete), "known defect - wait for autoclass fix"); }
public virtual void testModules14() { VString v = new VString("orig fullList end", null); for (int i = 0; i < v.Count; i++) { reSetUp(); string testType = v.stringAt(i); JDFAuditPool ap = n.getCreateAuditPool(); ap.appendXMLComment("JDF 1.3 incompatible auditing of module phases the REQUIRED time attributes are not set in the ModulePhase elements\n" + "- note that phases may now arbitrarily overlap\n" + "The modulePhase elements now only specify which modules are involved, times are all defined by the phasetime proper", null); ap.appendXMLComment("The following phaseTime is executed by one module - the RIP,which executes two process steps (Interpreting and Rendering)", null); JDFPhaseTime ptRIP = ap.addPhaseTime(EnumNodeStatus.Setup, null, null); JDFDate date = new JDFDate(); ptRIP.setStart(date); JDFDoc jmfDoc = new JDFDoc("JMF"); JDFJMF jmf = jmfDoc.getJMFRoot(); jmf.setDescriptiveName("Initial phase when the RIP starts up"); JDFSignal signal = jmf.appendSignal(JDFMessage.EnumType.Status); JDFDeviceInfo di = signal.appendDeviceInfo(); JDFJobPhase jpRIP = di.appendJobPhase(); di.setDeviceStatus(EnumDeviceStatus.Setup); jpRIP.setStartTime(date); jpRIP.setStatus(EnumNodeStatus.Setup); jpRIP.setJobID(n.getJobID(true)); jpRIP.setJobPartID(n.getJobPartID(true)); JDFModuleStatus msRIP = jpRIP.appendModuleStatus(); msRIP.setCombinedProcessIndex(new JDFIntegerList("0 1")); msRIP.setModuleType("Imaging"); msRIP.setModuleID("ID_Imaging"); JDFModulePhase mpRIP = ptRIP.appendModulePhase(); mpRIP.setCombinedProcessIndex(new JDFIntegerList("0 1")); mpRIP.setModuleType("Imaging"); mpRIP.setModuleID("ID_Imaging"); JDFModuleStatus msPrint = di.appendModuleStatus(); msPrint.setCombinedProcessIndex(new JDFIntegerList("2")); msPrint.setModuleType("Printer"); msPrint.setModuleID("ID_Printer"); JDFModuleStatus msStitch = di.appendModuleStatus(); msStitch.setCombinedProcessIndex(new JDFIntegerList("3")); msStitch.setModuleType("Stitcher"); msStitch.setModuleID("ID_Stitcher"); jmfDoc.write2File(sm_dirTestDataTemp + "moduleStatus" + testType + "0.jmf", 2, false); date.addOffset(0, 5, 0, 0); jmf.setTimeStamp(date); JDFJobPhase jpPrint = di.appendJobPhase(); di.setDeviceStatus(EnumDeviceStatus.Running); jpPrint.setStatus(EnumNodeStatus.InProgress); jpPrint.setStartTime(date); jpPrint.setJobID(n.getJobID(true)); jpPrint.setJobPartID(n.getJobPartID(true)); msPrint = jpPrint.appendModuleStatus(); msPrint.setCombinedProcessIndex(new JDFIntegerList("2")); msPrint.setModuleType("Printer"); msPrint.setModuleID("ID_Printer"); msStitch = jpPrint.appendModuleStatus(); msStitch.setCombinedProcessIndex(new JDFIntegerList("3")); msStitch.setModuleType("Stitcher"); msStitch.setModuleID("ID_Stitcher"); di.removeChildren(ElementName.MODULESTATUS, null, null); jmf.setDescriptiveName("Phase when the Printer and Finisher start up; RIP is still RIPping"); jmfDoc.write2File(sm_dirTestDataTemp + "moduleStatus" + testType + "1.jmf", 2, false); ap.appendXMLComment("The following phaseTime is executed by two modules - sticher and printer", null); JDFPhaseTime ptPrint = ap.addPhaseTime(EnumNodeStatus.InProgress, null, null); JDFModulePhase mpPrint = ptPrint.appendModulePhase(); mpPrint.setCombinedProcessIndex(new JDFIntegerList("2")); mpPrint.setModuleType("Printer"); mpPrint.setModuleID("ID_Printer"); ptPrint.setStart(date); JDFModulePhase mpStitch = ptPrint.appendModulePhase(); mpStitch.setCombinedProcessIndex(new JDFIntegerList("3")); mpStitch.setModuleType("Stitcher"); mpStitch.setModuleID("ID_Stitcher"); date.addOffset(0, 30, 0, 0); ptRIP.setEnd(date); JDFDeviceInfo di2 = null; if (i < 2) { JDFSignal signal2 = jmf.appendSignal(JDFMessage.EnumType.Status); di2 = (JDFDeviceInfo)signal2.copyElement(di, null); di2.removeChild(ElementName.JOBPHASE, null, 0); if (i == 1) { JDFModuleStatus directMSRip = (JDFModuleStatus)di2.copyElement(msRIP, null); directMSRip.setDeviceStatus(EnumDeviceStatus.Idle); } } else { jpRIP.setAttribute("EndTime", date.DateTimeISO); jpRIP.setDescriptiveName("Added EndTime to explicitly close phase"); } jmf.setTimeStamp(date); jmf.setDescriptiveName("Phase when the RIP has completed, Printer and Finisher are still RIPping"); jmfDoc.write2File(sm_dirTestDataTemp + "moduleStatus" + testType + "2.jmf", 2, false); date.addOffset(0, 70, 0, 0); ptPrint.setEnd(date); jmf.setTimeStamp(date); if (i < 2) { signal.deleteNode(); signal = jmf.appendSignal(JDFMessage.EnumType.Status); di = (JDFDeviceInfo)signal.copyElement(di2, null); di.removeChild(ElementName.JOBPHASE, null, 0); di.removeChild(ElementName.MODULESTATUS, null, 0); di.setDeviceStatus(EnumDeviceStatus.Idle); signal.appendXMLComment("Or should the complete list of modules also be specified here?", di); } else { jpRIP.deleteNode(); jpPrint.setAttribute("EndTime", date.DateTimeISO); jpPrint.setDescriptiveName("Added EndTime to explicitly close phase"); } jmf.setDescriptiveName("Phase when the Printer and Finisher have completed"); jmfDoc.write2File(sm_dirTestDataTemp + "moduleStatus" + testType + "3.jmf", 2, false); doc.write2File(sm_dirTestDataTemp + "DigiPrintModule.1.4" + testType + ".jdf", 2, false); } }
/// /// <summary> * Set the Status and StatusDetails of this node update the PhaseTime audit or append a new phasetime as appropriate /// * also prepare a status JMF /// * </summary> /// * <param name="nodeStatus"> the new status of the node </param> /// * <param name="nodeStatusDetails"> the new statusDetails of the node </param> /// * <param name="deviceStatus"> the new status of the device </param> /// * <param name="deviceStatusDetails"> the new statusDetails of the device </param> /// * <param name="vPartMap"> the vector of parts to that should be set </param> /// * <param name="vResLink"> the resourcelinks that are used to fill the various amount attributes in jobphase and phasetime /// * </param> /// public virtual void setPhase(EnumNodeStatus nodeStatus, string nodeStatusDetails, EnumDeviceStatus deviceStatus, string deviceStatusDetails, AmountBag[] amounts) { docJMFPhaseTime = new JDFDoc(ElementName.JMF); JDFJMF jmf = docJMFPhaseTime.getJMFRoot(); docJMFResource = new JDFDoc(ElementName.JMF); JDFJMF jmfRes = docJMFResource.getJMFRoot(); AmountBag ab = getBag(getFirstRefID(), amounts); LinkAmount la = getLinkAmount(getFirstRefID()); AmountBag lastAb = la == null ? null : la.lastBag; JDFAuditPool ap = m_Node.getCreateAuditPool(); // TODO rethink when to send 2 phases JDFPhaseTime pt1 = ap.getLastPhase(m_vPartMap, null); JDFPhaseTime pt2 = pt1; bool bEnd = nodeStatus.Equals(EnumNodeStatus.Completed) || nodeStatus.Equals(EnumNodeStatus.Aborted); pt2 = ap.setPhase(nodeStatus, nodeStatusDetails, m_vPartMap, null); if (bEnd) { JDFProcessRun pr = (JDFProcessRun)ap.addAudit(EnumAuditType.ProcessRun, null); pr.setPartMapVector(m_vPartMap); VElement audits = ap.getAudits(EnumAuditType.PhaseTime, null, m_vPartMap); for (int i = 0; i < audits.Count; i++) { pr.addPhase((JDFPhaseTime)audits[i]); } pr.setEndStatus(nodeStatus); } if (pt1 != null && pt2 != pt1) // we explicitly added a new phasetime // audit, thus we need to add a closing // JMF for the original jobPhase { JDFSignal s = (JDFSignal)jmf.appendMessageElement(JDFMessage.EnumFamily.Signal, JDFMessage.EnumType.Status); JDFDeviceInfo deviceInfo = s.appendDeviceInfo(); JDFJobPhase jp = deviceInfo.createJobPhaseFromPhaseTime(pt1); jp.setJobID(m_Node.getJobID(true)); jp.setJobPartID(m_Node.getJobPartID(false)); setJobPhaseAmounts(lastAb, jp); if (m_deviceID != null) { deviceInfo.setDeviceID(m_deviceID); } } if (pt2 != null) { JDFSignal s = (JDFSignal)jmf.appendMessageElement(JDFMessage.EnumFamily.Signal, JDFMessage.EnumType.Status); JDFDeviceInfo deviceInfo = s.appendDeviceInfo(); if (!bEnd) // don't write a jobphase for an idle device { JDFJobPhase jp = deviceInfo.createJobPhaseFromPhaseTime(pt2); setJobPhaseAmounts(ab, jp); } deviceInfo.setDeviceStatus(deviceStatus); deviceInfo.setStatusDetails(deviceStatusDetails); deviceInfo.setDeviceID(m_deviceID); m_Node.setPartStatus(m_vPartMap, nodeStatus, null); getVResLink(amounts, 2); // update the nodes links generateResourceSignal(amounts, jmfRes); if (bEnd) { pt2.deleteNode(); // zapp the last phasetime } else { pt2.setLinks(getVResLink(amounts, 1)); pt2.eraseEmptyAttributes(true); } } // cleanup! if (vLinkAmount != null) { for (int i = 0; i < vLinkAmount.Length; i++) { string refID = vLinkAmount[i].rl.getrRef(); AmountBag bag = getBag(refID, amounts); vLinkAmount[i].lastBag = new AmountBag(bag); } } jmf.eraseEmptyAttributes(true); }
public virtual void testStatusEquals() { // test if the auto classes implement the correct status // compare EnumNodeStatus JDFAuditPool myAuditPool = null; JDFDoc jdfDoc = new JDFDoc(ElementName.JDF); JDFNode jdfRoot = (JDFNode)jdfDoc.getRoot(); Assert.IsTrue(jdfRoot != null, "No Root found"); if (jdfRoot == null) { return; // soothe findbugs ;) } JDFAncestor ancestor = jdfRoot.appendAncestorPool().appendAncestor(); ancestor.setStatus(EnumNodeStatus.Completed); myAuditPool = jdfRoot.getCreateAuditPool(); JDFPhaseTime phaseTime = myAuditPool.addPhaseTime(JDFElement.EnumNodeStatus.Completed, null, null); JDFSpawned spawned = myAuditPool.addSpawned(jdfRoot, null, null, null, null); spawned.setStatus(JDFElement.EnumNodeStatus.Completed); Assert.AreEqual(spawned.getStatus(), phaseTime.getStatus()); Assert.AreEqual(spawned.getStatus(), ancestor.getStatus()); JDFDoc jmfDoc = new JDFDoc(ElementName.JMF); JDFJMF jmfRoot = jmfDoc.getJMFRoot(); Assert.IsTrue(jmfRoot != null, "No Root found"); if (jmfRoot == null) { return; // soothe findbugs ;) } JDFAcknowledge acknowledge = jmfRoot.appendAcknowledge(); acknowledge.setType("PipePush"); // Type is required and its existance // is validated for messages JDFJobPhase jobPhase = acknowledge.appendJobPhase(); jobPhase.setStatus(EnumNodeStatus.Completed); JDFMessage message = jmfRoot.appendMessageElement(EnumFamily.Command, null); message.setType("PipePush"); // Type is required and its existance is // validated for messages JDFPipeParams pipeParams = message.appendPipeParams(); pipeParams.setStatus(EnumNodeStatus.Completed); Assert.AreEqual(jobPhase.getStatus(), pipeParams.getStatus()); Assert.AreEqual(spawned.getStatus(), pipeParams.getStatus()); // compare EnumResStatus JDFDoc responseDoc = new JDFDoc(ElementName.RESPONSE); JDFResponse responseRoot = (JDFResponse)responseDoc.getRoot(); Assert.IsTrue(responseRoot != null, "No Root found"); if (responseRoot == null) { return; // soothe findbugs ;) } responseRoot.setType(ElementName.RESOURCE); JDFResourceInfo resInfo = responseRoot.appendResourceInfo(); resInfo.setResStatus(EnumResStatus.Available); JDFDoc commandDoc = new JDFDoc(ElementName.COMMAND); JDFCommand commandRoot = (JDFCommand)commandDoc.getRoot(); Assert.IsTrue(commandRoot != null, "No Root found"); if (commandRoot == null) { return; // soothe findbugs ;) } commandRoot.setType(ElementName.RESOURCE); JDFResourceCmdParams resCmdParams = commandRoot.appendResourceCmdParams(); resCmdParams.setResStatus(EnumResStatus.Available); Assert.AreEqual(resInfo.getStatus(), resCmdParams.getStatus()); // check EnumQueueStatus JDFDoc queueDoc = new JDFDoc(ElementName.QUEUE); JDFQueue queueRoot = (JDFQueue)queueDoc.getRoot(); Assert.IsTrue(queueRoot != null, "No Root found"); if (queueRoot == null) { return; // soothe findbugs ;) } queueRoot.setQueueStatus(EnumQueueStatus.Running); // check EnumQueueEntryStatus JDFQueueEntry queueEntry = queueRoot.appendQueueEntry(); queueEntry.setQueueEntryStatus(EnumQueueEntryStatus.Running); }
// // * (non-Javadoc) // * // * @see // * org.cip4.jdflib.util.QueueHotFolderListener#submitted(org.cip4.jdflib // * .jmf.JDFJMF) // public virtual void submitted(JDFJMF submissionJMF) { vJMF.Add(submissionJMF); }