Skip to content

Push

Installation

Installation Insight Push

Sending push messages

Push messages can be sent via HTTP-POST-Request.

  • URL: https://yourdomain.com/insight/push/push/send

  • Header: "Content-Type": "application/json"

  • POST-Data:

    {
      "title":"Headline",
      "message": "There is a new request",
      "users": [
        "maxadmin"
      ],
      "path": "workorder-quickrep/WORKORDER/60",
      "sound": "default"
    }
    
  • Available sounds:

    • default

    • alarmbuzzer.caf

    • demonstrative.caf

    • martiangun.caf

Example Maximo-Automation-Script

  • Script Language: Groovy

  • Source Code:

        import org.apache.commons.httpclient.*;
        import org.apache.commons.httpclient.methods.*;

        import psdi.mbo.*;
        import psdi.security.UserInfo;
        import psdi.server.MXServer;

        HttpClient client = new HttpClient();
        client.getHostConfiguration().setHost("localhost", 8080, "http");
        PostMethod post = new PostMethod("/insight-push/rest/push/send");
        post.addRequestHeader("Content-Type", "application/json; harset=utf-8");

        String status = mbo.getString("STATUS");
        if (!status.equals("INPRG")) {
            return;
        }

        MXServer mxServer = MXServer.getMXServer();
        UserInfo userInfo = mxServer.getUserInfo(user);
        MboSetRemote userset = mxServer.getMboSet("MAXUSER", userInfo);
        userset.setWhere("PERSONID in (select PERSONID from LABOR where
        LABORCODE in (select LABORCODE from LABORCRAFTRATE where CRAFT = '"+mbo.getString("CREWID")+"'))");
        userset.reset();

        int count = userset.count();

        if (count == 0) {
            return;
        }

        String userString = "";
        MboRemote currMbo = null;
        for (int i = 0; (currMbo = userset.getMbo(i)) != null; i++) {
            String login = currMbo.getString("LOGINID");
            userString += """ + login + """;
            if (i < count - 1) {
                userString += ",";
            }
        }

        String woUniqueId = String.valueOf(mbo.getUniqueIDValue());
        String message = "Neuer Arbeitsauftrag: " + mbo.getString("DESCRIPTION");
        String input = "{ "title":"Message", "message": "" + message + "", "users": [ " + userString + " ], "path": "workorder-quickrep/WORKORDER/" + woUniqueId + "", "sound": "default" }";

        try {
            post.setRequestBody(input);
            client.executeMethod(post);
            System.out.println("nStatus:");
            System.out.println(post.getStatusLine());
            String response = new
            String(post.getResponseBodyAsString().getBytes("8859_1"));
            System.out.println("nnResponse:");
            System.out.println(response);
        }
        catch (Exception e) {
            e.printStackTrace();
        }
        finally {
            post.releaseConnection();
        }