• Each service with a unique production WSDL provides a create, update, and query method. 
  • These methods work identically with the exception of Additional Form queries, the creation of Documents, and the submission of Requests.

The contract service also provides additional methods for handling additional parties. In each of these examples, the service has been created beforehand and named ``service.''

Create a New Entity

This will create a new entity on the server from an object that has been instantiated on the client side. The method returns the ID of the newly created object.

NovatusCompany company = new NovatusCompany();
company.setName("API created company");
company.setGroup("Primary")
   company.setStatus("Active");
String companyId = service.create(company);
CODE


For documents, the create method also requires a byte array with the contents of the file:

NovatusDocument document = new NovatusDocument();
// ... fill in document information with NovatusDocument setters
byte[] fileContents = Files.readAllBytes(Paths.get("path//to//file"));
service.create(document, fileContents);
CODE


Query an Object 

The query method will return a list of entities that match the query given. The signature of the method is:

query(String query, int pageSize, int page);
CODE

and it can be used for every object other than Additional Forms. For Additional Forms, a configuration ID that corresponds to the form type is also required: 


query(String query, String configId, int pageSize, int page);
CODE

where query is a string that conforms to the NQL description contained in this document, pageSize is the number of results to return for each call, and page is where the results should start, beginning with 0 (i.e., if there are 100 entities that match the query and a page size of 10 is used, page 0 will return the first 10 results, page 1 will return the next 10 results, and so on.) The maximum page size is 500. The query returns an object (called CompanyQueryResult, ContractQueryResult, etc.) that contains a list of objects and a total count (getTotalCount()).

A table of the objects is shown below:

Object Result Object ClassObject List Method
CompanyCompanyQueryResultgetCompanyList
ContractContractQueryResultgetContractList
DocumentDocumentQueryResultgetDocumentList
FormsFormQueryResultgetFormList
PaymentPaymentQueryResultgetPaymentList


For example, to obtain the company "AAA Software Company,'' ensuring that the company exists and there are no duplicates:

public NovatusCompany getMyCompany() {
   CompanyQueryResult cqr = service.query("name='AAA Software Company'", 1, 0);
   if(cqr.getTotalCount() != 1) {
      throw new RuntimeException("Company was not found.");
   }
   else {
      return cqr.getCompanyList().get(0);
   }
}
 
CODE


Furthermore, to include a query on a contract page when one is associating a contract with a company, then:

NovatusCompanyService companyPort = portCreators.company(sessionId);
NovatusContractService contractPort = portCreators.contract(sessionId);
 
CompanyQueryResult companies = companyPort.query("name='Company Name'", 25, 0);
NovatusCompany dbCompany = companies.getCompanyList().get(0);
 
NovatusContract contract = new NovatusContract();
NovatusCompany company = new NovatusCompany();
company.setId(dbCompany.getId());
		
contract.setCompany(company);
CODE


Update Objects

The update method works identically to the create method, with the difference that the objects passed into the update method MUST have been obtained via a query from the server and NOT created on the client side. Using the getMyCompany() method above, we can change something in the company and update it on the server: 

NovatusCompany aaa = getMyCompany();
aaa.setGroup("Customers");
service.update(aaa);
CODE


How to Query on Date Fields

Important notes on setting up queries for date fields:

  • It is recommended to use constraints instead of the = sign.  This is because the = will look for the exact time stamp in which the document was uploaded (down to the millisecond)
  • Use the standard SQL date format ‘YYYY-MM-DD’
DocumentQueryResult documents = documentPort.query("createdon < '2016-01-22' and createdon > '2016-01-20'", 25, 0);
CODE