Package org.intalio.tempo.workflow.tms.client

Examples of org.intalio.tempo.workflow.tms.client.TempoClient


        Property[] props = client.getTokenProperties(token);
        String user = (String) PropertyUtils.getProperty(props, AuthenticationConstants.PROPERTY_USER).getValue();
        _log.info("Decrypting the token properties. We have successfully logged in as:" + user);

        _log.info("Instanciate tms service client");
        TempoClient tempoClient = new TempoClient("http://localhost:8080", token, client);
        //RemoteTMSClient tms = new RemoteTMSClient(TMS_SERVICE, token);

        _log.info("get the pipa corresponding to the absence request, by making a query on our available tasks");
        Task[] ts = tempoClient.getAvailableTasks("PIPATask", "T._description like '%Examples%'");

        String pipaID = ts[0].getID();
        _log.info("We have found the task to instanciate the process. This task has the following ID:" + pipaID);
        tempoClient.init(pipaID, tempoClient.createMessageAsDocument(pipa, "abr_initPipa.ftl"));
        _log.info("wait for the task to be initiated. Hopefully 2s is enough");
        Thread.sleep(SLEEP_TIME);

        _log.info("get our full activity task list");
        Task[] paList = tempoClient.getAvailableTasks("PATask", "ORDER BY T._creationDate DESC");
        _log.info("get the id of the activity task");
        String id = paList[0].getID();
        _log.info("We're about to start using PATask with id:" + id);

        _log.info("We cannot get input and output of a task on a get task list call (see WSDL)");
        _log.info("Let's call TMS again to get the full input and output data of this PATask");
        PATask task = (PATask) tempoClient.getTask(id);
        _log.info("" + "\nChecking the task metadata..." + "\nThe task has been created on:" + task.getCreationDate() + "\nIt has the following description:"
                        + task.getDescription() + "\nIt is attached to the process with id:" + task.getProcessID() + "\nIt is attached to the following form:"
                        + task.getFormURLAsString() + "\nIt is in the following state:" + task.getState() + "\nIt has the following input:\n"
                        + task.getInputAsXmlString() + "\nIt can be assigned to the following roles:" + task.getRoleOwners()
                        + "\nIt can be assigned to the following users:" + task.getUserOwners());

        _log.info("Let's claim the task: no one else can access this task apart from user:" + user);
        tempoClient.claim(id, user);
        _log.info("Let's revoke the task:every one can access this task again");
        tempoClient.revoke(id);
        _log.info("Call setoutput from TMS Client");
        tempoClient.setOutput(id, tempoClient.createMessageAsDocument(complete, "abr_output.ftl"));
        _log.info("Check the output we've just set");
        String outputAsXmlString = ((PATask)tempoClient.getTask(id)).getOutputAsXmlString();
    _log.info(outputAsXmlString);
        _log.info("complete the PA task with some output");
        tempoClient.complete(id, complete, "abr_output.ftl");
        //sendSoapToTMP(complete(token, id, complete), "completeTask");

        _log.info("sleep again to wait for the notification");
        Thread.sleep(SLEEP_TIME);
        Task[] ts2 = tempoClient.getAvailableTasks("Notification", "ORDER BY T._creationDate DESC");
        String notificationId = ts2[0].getID();
        _log.info("We want to retrieve some more data on the notification with id:" + notificationId);
        Notification notification = (Notification) tempoClient.getTask(notificationId);

        _log.info("The notification has the following:" + "\nInput:" + xmlTooling.serializeXML(notification.getInput()) + "\nCreation Date:"
                        + notification.getCreationDate() + "\nAttached Form:" + notification.getFormURLAsString() + "\nDescription:"
                        + notification.getDescription());

        _log.info("Dismiss this notification");
        tempoClient.complete(notificationId);
    }
View Full Code Here


        TokenClient client = new TokenClient(TOKEN_SERVICE);
        String token = client.authenticateUser(paramUser, paramPassword);

        _log.info("get the tms client");
        //RemoteTMSClient tms = new RemoteTMSClient(TMS_SERVICE, token);
        TempoClient tempoClient = new TempoClient("http://localhost:8080", token, client);
       
        _log.info("get the absence request PIPA");
        Task[] ts = tempoClient.getAvailableTasks("PIPATask", "T._description like '%Examples%'");
        String pipaID = ts[0].getID();

        _log.info("Init the process and wait");
        tempoClient.init(pipaID, tempoClient.createMessageAsDocument(pipa, "abr_initPipa.ftl"));
        Thread.sleep(SLEEP_TIME);

        _log.info("check the new task has appeared");
        Task[] paList = tempoClient.getAvailableTasks("PATask", "T._state = TaskState.READY ORDER BY T._creationDate DESC");
        String id = paList[0].getID();

        _log.info("keep track of the current time");
        long currentTime = System.currentTimeMillis();

        _log.info("do the optional call.");

        // skip needs to be called on TMP first.
        if (optionalCall.equals("skip"))
            tempoClient.skip(id);
        else if (optionalCall.equals("fail"))
          tempoClient.fail(id, "0", "Error message");
        else if (optionalCall.equals("delete"))
          tempoClient.delete(new String[] { id });
        else if (optionalCall.equals("deleteAll"))
          tempoClient.deleteAll("false", "T._state = TaskState.READY", "PATask");
        else if (optionalCall.equals("reassign"))
            tempoClient.reassign(id, "examples/msmith");
        else
            throw new Exception("invalid optional call:" + optionalCall);

        _log.info("wait some more so that we process the optional call");
        Thread.sleep(SLEEP_TIME);

        _log.info("check the task has disappeared. All the call we've done make the task not showing the user task list anymore");
        Task[] ts2 = tempoClient.getAvailableTasks("PATask", "T._state = TaskState.READY ORDER BY T._creationDate DESC");
        Assert.assertEquals(0, ts2.length);

        if (optionalCall.equals("skip")) {
            _log.info("for skip, we're doing one extra check to see if the state of the task is appropriately OBSOLETE");
            Task[] ts3 = tempoClient.getAvailableTasks("PATask", "T._state = TaskState.OBSOLETE ORDER BY T._creationDate DESC");
            long time = currentTime - ts3[0].getCreationDate().getTime();
            Assert.assertTrue(time > 0);
            Assert.assertTrue(time < 5000); // 2*SLEEP_TIME + 1s of computer
            // work margin
        }
View Full Code Here

     */
    private void runAbsenceRequestWithRandomClaimRevokeTMPCalls(String paramUser, String paramPassword, HashMap pipa, HashMap complete) throws Exception {
        TokenClient client = new TokenClient(TOKEN_SERVICE);
        String token = client.authenticateUser(paramUser, paramPassword);
        //RemoteTMSClient tms = new RemoteTMSClient(TMS_SERVICE, token);
        TempoClient tempoClient = new TempoClient("http://localhost:8080", token, client);
        Task[] ts = tempoClient.getAvailableTasks("PIPATask", "T._description like '%Examples%'");
        String pipaID = ts[0].getID();
        tempoClient.init(pipaID, tempoClient.createMessageAsDocument(pipa, "abr_initPipa.ftl"));
        Thread.sleep(SLEEP_TIME);
        String id = tempoClient.getAvailableTasks("PATask", "T._description like '%Approval%' ORDER BY T._creationDate DESC")[0].getID();
        SecureRandom r = new SecureRandom();
        for (int i = 0; i < 10; i++) {
            if (r.nextBoolean()) {
              tempoClient.claim(id, paramUser);
            } else {
              tempoClient.revoke(id);
            }
        }
    }
View Full Code Here

   
    // prepare the token
    TokenClient client = new TokenClient(TOKEN_SERVICE);
    String token = client.authenticateUser(paramUser, paramPassword);
    // testing client, including call to TMS, TMP
    TempoClient tempoClient = new TempoClient("http://localhost:8080", token, client);

   
    // search PIPA tasks using wild card description
    Task[] ts = tempoClient.getAvailableTasks("PIPATask", "T._description like '%Examples%'");
   
    // search PA tasks, using state, wildcard description, order by date
    StringBuilder query = new StringBuilder();
    query.append("(T._state = TaskState.READY OR T._state = TaskState.CLAIMED)");
    query.append(" AND ");
    query.append("T._description like '%Examples%'");
    query.append(" ");
    query.append("ORDER BY T._creationDate DESC");
   
    Long countTasks = tempoClient.countAvailableTasks(PATask.class.getSimpleName(), query.toString());
    _log.info(MessageFormat.format("Found {0} tasks with description like %Examples%", countTasks));
    // retrieve all the tasks
    Task[] paList = tempoClient.getAvailableTasks("PATask", query.toString());
    // retrieve only a few tasks by setting min and max
    Task[] aFewTasks = tempoClient.getAvailableTasks("PATask", query.toString(), String.valueOf(0), String.valueOf(5));
    _log.info(MessageFormat.format("Collecting {0} tasks with description like %Examples%", aFewTasks.length));

  }
View Full Code Here

TOP

Related Classes of org.intalio.tempo.workflow.tms.client.TempoClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.