🖍️
Dataloy VMS API Documentation
API Release 8.6
API Release 8.6
  • Dataloy VMS API
  • Dataloy Rest API
    • What is it?
    • Authentication / Authorization
    • Getting Started
    • Data Model
    • Filtering
    • Sorting
    • Pagination
    • Adjust Number of Fields to be Returned from a Request
    • Webhooks
      • Webhook example
      • Expressions Made Easy
      • Webhooks - New functionalities
    • Master data Objects
    • Attachments
    • Audit Log
  • User Guides
    • Accounting Integration API
      • Invoicing
      • Payments/Receipts
      • Voyages
      • Business Partners
      • Exchange Rates
      • Bunker Transactions
      • Actuals
      • Autopost Invoices
      • Accruals
    • Schedule API
    • Bunker Order Integration API
    • Service Order Integration API
    • Vessel Report
      • Overview
      • Legacy version (6.26 - 6.28)
      • Vessel report master data
    • Bunker Consumption API
    • Left join in API queries
    • Enterprise functionalities
      • Versioning
      • Endpoint access control
      • Data access control via target object
      • Data access control via target object and security role
      • Data access control at object level
      • Fields access control
      • Alert Scripts
      • Websockets
      • Bulk Deletion
      • Copy objects
      • OR and AND operators in API queries
      • Sub queries
      • XML Transformation
      • Expressions
      • Bulk Update
Powered by GitBook
On this page
  • Bunker price
  • Bunker quantity
  • Bunker date
  • Offhire start date
  • Days in port updated
  • ETA outside laycan

Was this helpful?

Export as PDF
  1. User Guides
  2. Enterprise functionalities

Alert Scripts

It is possible to create scripts, written in pseudo Java, that can be injected at runtime and used by Webhooks and Websockets.

An Alert Script can be very simple or very complex, their scope is to evaluate conditions and return true or false. If the script returns true the message is sent.

Alerts can be created and installed at run-time into the system. These are the predefined alerts available:

Bunker price

import com.dataloy.ds.*;
import com.dataloy.*;
import java.math.*;
BunkerOrderLine bunkerOrderLineOld= null;
BunkerOrderLine bunkerOrderLineNew= null;
if(dlpObject instanceof BunkerOrderLine)
    bunkerOrderLineNew=  dlpObject;
if(oldDlpObject instanceof BunkerOrderLine)
    bunkerOrderLineOld=  oldDlpObject;
if( bunkerOrderLineOld!=null && bunkerOrderLineNew!=null && ((bunkerOrderLineOld.getUnitPrice()==null && bunkerOrderLineNew.getUnitPrice()!=null) || (bunkerOrderLineOld.getUnitPrice()!=null && bunkerOrderLineNew.getUnitPrice()==null) ||    !bunkerOrderLineNew.getUnitPrice().equals(bunkerOrderLineOld.getUnitPrice()))){
    mapResultsForMessage.put("?1",bunkerOrderLineNew.getBunkerType().getBunkerTypeDesc());
    mapResultsForMessage.put("?2",bunkerOrderLineNew.getBunkerOrder().getPortCall().getVoyage().getVessel().getVesselName());
    if(bunkerOrderLineNew.getBunkerOrder().getPortCall().getVoyage().getVoyageHeader()!= null && bunkerOrderLineNew.getBunkerOrder().getPortCall().getVoyage().getVoyageHeader().getReferenceNo()!=null)
        mapResultsForMessage.put("?3",bunkerOrderLineNew.getBunkerOrder().getPortCall().getVoyage().getVoyageHeader().getReferenceNo());
    else
        mapResultsForMessage.put("?3",bunkerOrderLineNew.getBunkerOrder().getPortCall().getVoyage().getKey());
     
    mapResultsForMessage.put("?4",bunkerOrderLineNew.getBunkerOrder().getPortCall().getPort().getPortName());
     
    Double value1= new BigDecimal(bunkerOrderLineNew.getUnitPrice()).setScale(2, RoundingMode.HALF_UP).doubleValue();
    Double value2= new BigDecimal(bunkerOrderLineOld.getUnitPrice()).setScale(2, RoundingMode.HALF_UP).doubleValue();
     
     
    String strValue1= value1.toString();
    String appValue1= strValue1.substring(strValue1.indexOf(".")+1, strValue1.length());
    while(appValue1.length()<2)
        appValue1= appValue1 +0;
    String finalValue1= strValue1.substring(0,strValue1.indexOf(".")+1)+appValue1;
     
     
    String strValue2= value2.toString();
    String appValue2= strValue2.substring(strValue2.indexOf(".")+1, strValue2.length());
    while(appValue2.length()<2)
        appValue2= appValue2 +0;
    String finalValue2= strValue2.substring(0,strValue2.indexOf(".")+1)+appValue2;
     
     
    mapResultsForMessage.put("?5",finalValue1  );
    mapResultsForMessage.put("?6",finalValue2  );
     
     
    return true;
}
else{
    return false;
}

Bunker quantity

import com.dataloy.ds.*;
import com.dataloy.*;
import java.math.*;
BunkerOrderLine bunkerOrderLineOld= null;
BunkerOrderLine bunkerOrderLineNew= null;
if(dlpObject instanceof BunkerOrderLine)
    bunkerOrderLineNew=  dlpObject;
if(oldDlpObject instanceof BunkerOrderLine)
    bunkerOrderLineOld=  oldDlpObject;
if( bunkerOrderLineOld!=null && bunkerOrderLineNew!=null && ((bunkerOrderLineOld.getBunkeredQuantity()==null && bunkerOrderLineNew.getBunkeredQuantity()!=null) || (bunkerOrderLineOld.getBunkeredQuantity()!=null && bunkerOrderLineNew.getBunkeredQuantity()==null) ||    !bunkerOrderLineNew.getBunkeredQuantity().equals(bunkerOrderLineOld.getBunkeredQuantity()))){
    mapResultsForMessage.put("?1",bunkerOrderLineNew.getBunkerType().getBunkerTypeDesc());
    mapResultsForMessage.put("?2",bunkerOrderLineNew.getBunkerOrder().getPortCall().getVoyage().getVessel().getVesselName());
    if(bunkerOrderLineNew.getBunkerOrder().getPortCall().getVoyage().getVoyageHeader()!= null && bunkerOrderLineNew.getBunkerOrder().getPortCall().getVoyage().getVoyageHeader().getReferenceNo()!=null)
        mapResultsForMessage.put("?3",bunkerOrderLineNew.getBunkerOrder().getPortCall().getVoyage().getVoyageHeader().getReferenceNo());
    else
        mapResultsForMessage.put("?3",bunkerOrderLineNew.getBunkerOrder().getPortCall().getVoyage().getKey());
     
    mapResultsForMessage.put("?4",bunkerOrderLineNew.getBunkerOrder().getPortCall().getPort().getPortName());
     
    Double value1= new BigDecimal(bunkerOrderLineNew.getBunkeredQuantity()).setScale(3, RoundingMode.HALF_UP).doubleValue();
    Double value2= new BigDecimal(bunkerOrderLineOld.getBunkeredQuantity()).setScale(3, RoundingMode.HALF_UP).doubleValue();
     
     
    String strValue1= value1.toString();
    String appValue1= strValue1.substring(strValue1.indexOf(".")+1, strValue1.length());
    while(appValue1.length()<3)
        appValue1= appValue1 +0;
    String finalValue1= strValue1.substring(0,strValue1.indexOf(".")+1)+appValue1;
     
     
    String strValue2= value2.toString();
    String appValue2= strValue2.substring(strValue2.indexOf(".")+1, strValue2.length());
    while(appValue2.length()<3)
        appValue2= appValue2 +0;
    String finalValue2= strValue2.substring(0,strValue2.indexOf(".")+1)+appValue2;
     
     
     
    mapResultsForMessage.put("?5",finalValue1 );
    mapResultsForMessage.put("?6",finalValue2 );
    return true;
}
else{
    return false;
}

Bunker date

import com.dataloy.ds.*;
import com.dataloy.*;
import java.text.*;
BunkerOrder bunkerOrderOld= null;
BunkerOrder bunkerOrderNew= null;
if(dlpObject instanceof BunkerOrder)
    bunkerOrderNew=  dlpObject;
if(oldDlpObject instanceof BunkerOrder)
    bunkerOrderOld=  oldDlpObject;
if( bunkerOrderOld!=null && bunkerOrderNew!=null && ((bunkerOrderOld.getBunkeredDate()==null && bunkerOrderNew.getBunkeredDate()!=null) || (bunkerOrderOld.getBunkeredDate()!=null && bunkerOrderNew.getBunkeredDate()==null) ||    !bunkerOrderNew.getBunkeredDate().equals(bunkerOrderOld.getBunkeredDate()))){
    mapResultsForMessage.put("?1",bunkerOrderNew.getKey());
    mapResultsForMessage.put("?2",bunkerOrderNew.getPortCall().getVoyage().getVessel().getVesselName());
    if(bunkerOrderNew.getPortCall().getVoyage().getVoyageHeader()!= null && bunkerOrderNew.getPortCall().getVoyage().getVoyageHeader().getReferenceNo()!=null)
        mapResultsForMessage.put("?3",bunkerOrderNew.getPortCall().getVoyage().getVoyageHeader().getReferenceNo());
    else
        mapResultsForMessage.put("?3",bunkerOrderNew.getPortCall().getVoyage().getKey());
     
    mapResultsForMessage.put("?4",bunkerOrderNew.getPortCall().getPort().getPortName());
     
     
     SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd.MM.yyyy hh:mm");
     String date1 = DATE_FORMAT.format(bunkerOrderNew.getBunkeredDate());
     String date2 = DATE_FORMAT.format(bunkerOrderOld.getBunkeredDate());
     
    mapResultsForMessage.put("?5",date1);
    mapResultsForMessage.put("?6",date2);
    return true;
}
else{
    return false;
}

Offhire start date

import com.dataloy.ds.*;
import com.dataloy.*;
import java.math.*;
import java.util.*;
 
        Offhire offhireInput= null;
        Voyage voyage= null;
        VoyageHeader voyageHeader= null;
        java.lang.System.out.println("---- offhire");
         
        if(dlpObject instanceof Voyage)
            voyage= dlpObject;
        if(dlpObject instanceof VoyageHeader)
            voyageHeader= dlpObject;
        if(dlpObject instanceof Offhire)
            offhireInput= dlpObject;
             
        List offhires= new ArrayList();
        if(offhireInput!=null) {
            offhires.add(offhireInput);
        }
        if(voyageHeader!=null){
            offhires= voyageHeader.getOffhires();
        }
        if(voyage!=null && voyage.getVoyageHeader()!=null){
            offhires= voyage.getVoyageHeader().getOffhires();
        }
        if(offhires!=null && !offhires.isEmpty()){     
            for (Offhire offhire : offhires) {     
                if(offhire!=null && offhire.getVoyageHeader()!=null){
                    java.lang.System.out.println("---- offhire="+offhire);
                    if(offhire.getOffhireStartDate() == null || offhire.getOffhireEndDate() == null || offhire.getVoyageHeader().getVoyageStartDate() == null){
                        return false;
                    }
                    int hcons = 60 * 60 * 1000;
                    int dcons = hcons * 24;
                     
                     
                    java.lang.System.out.println("---- offhire offhire.getTimezoneOffset()="+offhire.getTimezoneOffset());
                    java.lang.System.out.println("---- offhire offhire.getOffhireStartDate()="+offhire.getOffhireStartDate().getTime());
                    Double offStart = offhire.getOffhireStartDate().getTime() - offhire.getTimezoneOffset() * hcons;
                    java.lang.System.out.println("---- offhire offStart="+offStart);
                    Calendar triggerStart = Calendar.getInstance();
                    triggerStart.add(Calendar.YEAR, -1);
                     
                    if(offStart < triggerStart.getTimeInMillis()){
                        return false;
                    }
                     
                    Double offEnd = offhire.getOffhireEndDate().getTime() - offhire.getTimezoneOffset()  * hcons;
             
                    Double voyStart = offhire.getVoyageHeader().getVoyageStartDate().getTime() -( offhire.getVoyageHeader().getTimezoneOffset() * hcons);
                    Double voyEnd = voyStart + offhire.getVoyageHeader().getVoyage().getDaysTotal() * dcons;
             
                     
                    if(offStart < voyStart || offEnd > voyEnd){
                        mapResultsForMessage.put("?1",offhire.getVoyageHeader().getVoyage().getVessel().getVesselName());
                        mapResultsForMessage.put("?2",offhire.getVoyageHeader().getReferenceNo());
                        mapResultsForMessage.put("?3",offhire.getOffhireStartDate());
                        mapResultsForMessage.put("?4",offhire.getOffhireEndDate());
                        return true;
                    }
                }
                     
            }
        }
        else
            return false;

Days in port updated

import com.dataloy.ds.*;
import com.dataloy.*;
import java.math.*;
import java.util.*;
 
        PortCall portCall= null;
        PortCall portCallOld= null;
 
        if(dlpObject instanceof PortCall)
            portCall= dlpObject;
             
             
       if(oldDlpObject instanceof PortCall)
            portCallOld=  oldDlpObject;        
             
        if(portCall!=null &&  portCallOld!=null ) {
            java.lang.System.out.println("---- daysInPort IF");
             
             
            try{
             
                double diff= portCall.getDaysInPort() - portCallOld.getDaysInPort();
                if((diff < -1 || diff > 1)) {
                    mapResultsForMessage.put("?1",portCall.getPort().getPortName());
                    mapResultsForMessage.put("?2",portCall.getVoyage().getVessel().getVesselName());
                    mapResultsForMessage.put("?3",portCall.getVoyage().getVoyageHeader().getReferenceNo());
                    mapResultsForMessage.put("?4",portCall.getDaysInPort());
                    return true;
                }
            }
            catch(Exception e){
                java.lang.System.out.println("---- daysInPort Exception");
            }
        }
     
        return false;

ETA outside laycan

import com.dataloy.ds.*;
import com.dataloy.*;
import java.math.*;
Cargo cargoOld= null;
Cargo cargoNew= null;
if(dlpObject instanceof Cargo)
    cargoNew=  dlpObject;
if(oldDlpObject instanceof Cargo)
    cargoOld=  oldDlpObject;
if( cargoOld!=null && cargoNew!=null && ((cargoOld.getLaycanMissedBy()==null && cargoNew.getLaycanMissedBy()!=null) || (cargoOld.getLaycanMissedBy()!=null && cargoNew.getLaycanMissedBy()==null) || !cargoNew.getLaycanMissedBy().equals(cargoOld.getLaycanMissedBy()))){
     
    String early = null;
     
    if(cargoNew.getLaycanMissedBy()==0){
        return false;
    }
 
    if(cargoNew.getLaycanMissedBy()<0){
        early = "early";
    }
 
    if(cargoNew.getLaycanMissedBy()>0){
        early = "late";
    }
     
    mapResultsForMessage.put("?1",cargoNew.getVoyage().getVessel().getVesselName());
    if(cargoNew.getVoyage().getVoyageHeader()!= null && cargoNew.getVoyage().getVoyageHeader().getReferenceNo()!=null)
        mapResultsForMessage.put("?4",cargoNew.getVoyage().getVoyageHeader().getReferenceNo());
    else
        mapResultsForMessage.put("?4",cargoNew.getVoyage().getKey());
 
    mapResultsForMessage.put("?2",early);
    mapResultsForMessage.put("?3",cargoNew.getCargoReference());
     
    Double value1= new BigDecimal(cargoNew.getLaycanMissedBy()).setScale(2, RoundingMode.HALF_UP).doubleValue();
     
    String strValue1= value1.toString();
    String appValue1= strValue1.substring(strValue1.indexOf(".")+1, strValue1.length());
    while(appValue1.length()<3)
        appValue1= appValue1 +0;
    String finalValue1= strValue1.substring(0,strValue1.indexOf(".")+1)+appValue1;
     
    mapResultsForMessage.put("?5",finalValue1 );
 
    return true;
}
else{
    return false;
}
PreviousFields access controlNextWebsockets

Was this helpful?