Class Session

java.lang.Object
com.primavera.integration.client.Session
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
DistributedSession, LocalSession

public abstract class Session extends Object implements Closeable

Session is the main class used for communicating with the server. A static login method is used to establish a valid session, that can then be used to access other main objects, such as the EnterpriseLoadManager and the JobManager. Logging in requires a valid database instance to be specified if multiple instances were defined, but a list of available database instances can be retrieved by calling getDatabaseInstances(), even without first logging in.

Note that the only differences in client code between Local Mode and Remote Mode is the calls to getDatabaseInstances() and login(). For Remote Mode, the URL of the RMI server needs to be specified. The RMIURL helper class can be used to create the URL.

Session is not a singleton, meaning you can establish multiple simultaneous sessions communicating with different servers and/or database instances. This can be useful for integrating with multiple Primavera databases.

When you are done working with the API, you should call logout() to release the session.

  • Field Details

    • BATCH_OVERRIDE

      public static final String BATCH_OVERRIDE
      Batch over-ride system property. Setting this property allows the user to specify arbitrary upper limit on batch sizes.
      See Also:
    • DEFAULT_LOCAL_BATCH_SIZE

      public static final int DEFAULT_LOCAL_BATCH_SIZE
      The default batch size for loading business objects in Local Mode.
      See Also:
    • MAX_BUSINESS_OBJECT_BATCH_SIZE

      public static final int MAX_BUSINESS_OBJECT_BATCH_SIZE
      The maximum batch size for loading the business objects.
      See Also:
    • MIN_BUSINESS_OBJECT_BATCH_SIZE

      public static final int MIN_BUSINESS_OBJECT_BATCH_SIZE
      The minimum batch size for loading the business objects.
      See Also:
    • MAX_BIND_PARAM_LIMIT_ON_LOAD

      public static final int MAX_BIND_PARAM_LIMIT_ON_LOAD
      The maximum where clause bind parameter limit
      See Also:
    • MIN_BIND_PARAM_LIMIT_ON_LOAD

      public static final int MIN_BIND_PARAM_LIMIT_ON_LOAD
      The minimum where clause bind parameter limit
      See Also:
    • DEFAULT_BIND_PARAM_LIMIT_ON_LOAD

      public static final int DEFAULT_BIND_PARAM_LIMIT_ON_LOAD
      The default where clause bind parameter limit
      See Also:
    • DEFAULT_REMOTE_BATCH_SIZE

      public static final int DEFAULT_REMOTE_BATCH_SIZE
      The default batch size for loading business objects in Remote Mode.
      See Also:
  • Constructor Details

    • Session

      public Session()
  • Method Details

    • isLocalModeAvailable

      public static boolean isLocalModeAvailable()
      Indicates whether Local Mode is available.
      Returns:
      true if Local Mode is available, false otherwise.
    • isRemoteModeAvailable

      public static boolean isRemoteModeAvailable()
      Indicates whether Remote Mode is available.
      Returns:
      true if Remote Mode is available, false otherwise.
    • getDatabaseInstances

      public static DatabaseInstance[] getDatabaseInstances(String sUrl) throws ServerException, NetworkException, ClientException
      Retrieves all database instances supported by the server. If the URL parameter is null, Local Mode is used. Otherwise, Remote Mode is used. You can use the isRemoteModeAvailable and isLocalModeAvailable methods to check if the specific modes are available. Note that instances can be added to a configuration using the Primavera Administrator utility. See the Integration API Installation Guide for more information.

      Parameters:
      sUrl - the location of the server, or null for Local Mode. Use the RMIURL class to create the URL.
      Returns:
      DatabaseInstance[] array of DatabaseInstance objects representing available databases
      Throws:
      ServerException - if a problem occurred on the server-side
      ClientException - if a problem occurred on the client-side
      NetworkException - if a problem occurred in the network layer
      See Also:
    • login

      public static Session login(String sUrl, String sDbId, String sUserName, String sPassword) throws ServerException, NetworkException, ClientException
      Throws:
      ServerException
      NetworkException
      ClientException
    • login

      public static Session login(String sUrl, String sDbId, String sUserName, String sPassword, String remoteClientIP) throws ServerException, NetworkException, ClientException
      Logs in and obtains a Session object.
      if the URL parameter is null, Local Mode is used. Otherwise, Remote Mode is used. Please use isRemoteModeAvailable and isLocalModeAvailable methods to check if the specific mode is available.
      Parameters:
      sUrl - the location of the server, or null for Local Mode. Use the RMIURL class to create the URL.
      sDbId - the database instance id
      sUserName - the user name
      sPassword - the password
      Returns:
      Session session object
      Throws:
      ServerException - if a problem occurred on the server-side
      ClientException - if a problem occurred on the client-side
      NetworkException - if a problem occurred in the network layer
      See Also:
    • logout

      public abstract void logout()
      Notifies the server that this session is no longer needed and releases any resources allocated for this session. You should always call logout after you finish working with the API.
    • isValid

      public abstract boolean isValid() throws NetworkException
      Verifies if the session is valid.
      Returns:
      true if session is valid
      Throws:
      NetworkException
    • getUserObjectId

      public abstract ObjectId getUserObjectId() throws ServerException, NetworkException
      Retrieves the ObjectId of the User who is logged in using this Session instance.
      Returns:
      ObjectId the user object id
      Throws:
      ServerException - if a problem occurred on the server-side
      NetworkException - if a problem occurred in the network layer
    • getGlobalObjectManager

      public GlobalObjectManager getGlobalObjectManager()
      Gets the GlobalObjectManager for this session.
      Returns:
      GlobalObjectManager the global object manager
    • getEnterpriseLoadManager

      public EnterpriseLoadManager getEnterpriseLoadManager()
      Gets the EnterpriseLoadManager for this session.
      Returns:
      EnterpriseLoadManager the enterprise load manager
    • getJobManager

      public JobManager getJobManager()
      Gets the JobManager for this session.
      Returns:
      JobManager the job manager
    • getDatabaseInstanceId

      public String getDatabaseInstanceId()
      Retrieves the database instance ID used to login and establish this session.
      Returns:
      String the current database instance ID
    • getUserName

      public String getUserName()
      Retrieves the name of the User who is logged in using this Session instance.
      Returns:
      String the current user name
    • getDatabaseUrl

      public String getDatabaseUrl()
      Retrieves the URL of the database this session is logged into.
      Returns:
      database url, including machine name and port number.
    • getDatabaseName

      public String getDatabaseName()
      Retrieves the name of the database this session is logged into.
      Returns:
      database name
    • getDatabaseType

      public int getDatabaseType()
      Retrieves the database type this session is logged into.
      Returns:
      database type ( Oracle = 0, SQL Server = 1, Otherwise = -1)
    • getDatabaseTypeEnum

      public DBType getDatabaseTypeEnum()
      Retrieves the database type this session is logged into.
      Returns:
      database type
    • getDatabaseEncoding

      public String getDatabaseEncoding()
      Retrieves the database encoding this session is logged into
      Returns:
      encoding
    • getBusinessObjectBatchSize

      public int getBusinessObjectBatchSize()
      Retrieves the current batch size for loading business objects.
      Returns:
      int the current batch size for loading business objects
    • setBusinessObjectBatchSize

      public void setBusinessObjectBatchSize(int iBatchSize) throws ClientException
      Set the new batch size for loading business objects.
      Parameters:
      iBatchSize - the new batch size for loading business objects
      Throws:
      ClientException - the new batch size was wrong
    • getBindParameterLimitOnLoad

      public int getBindParameterLimitOnLoad()
      Retrieves the current limit on bind parameters
      Returns:
      int the current limit on bind parameter
    • setBindParameterLimitOnLoad

      public void setBindParameterLimitOnLoad(int iBindParameterLimit) throws ClientException
      Set the new bind parameter limit for loading business objects. The bind parameter limit is used to determine if a prepared statement or where criteria is used to load business objects.
      Parameters:
      iBindParameterLimit - the new bind parameter limit for loading business objects
      Throws:
      ClientException - the new bind parameter limit is outside of acceptable range
    • getUSessionId

      public abstract ObjectId getUSessionId() throws ServerException, NetworkException
      Returns and ObjectId representation of the usession id
      Returns:
      ObjectId USessionId
      Throws:
      ServerException - if a problem occurred on the server-side
      NetworkException
    • pagingLoad

      public <T extends BusinessObject> com.primavera.integration.client.bo.BOPaging<T> pagingLoad(com.primavera.bo.defs.BusinessObjectDef boDef, String[] aIntgFieldName, String sWhereClause, String sOrderBy, com.primavera.bo.common.PRequestOptions opts, com.primavera.bo.base.RemoteTXId txId, int pageSize, String pageKey) throws ServerException, BusinessObjectException, NetworkException
      Throws:
      ServerException
      BusinessObjectException
      NetworkException
    • removeDeletedObjectsFromBaseline

      public int removeDeletedObjectsFromBaseline(String boTypeName, ObjectId origProjectId, ObjectId blProjectId, Collection<String> parentActivityIdsToConsider) throws ServerException
      Removes certain child objects from a baseline which do not exist in the original project This method is only supported for local sessions.
      Parameters:
      boTypeName - - the type of objects to remove. Supported type names are ["ActivityCodeAssignment", "ActivityUDFValue"]
      origProjectId - - ObjectId of original project
      blProjectId - - ObjectId of the baseline project
      parentActivityIdsToConsider - - If non-null, only the child objects owned by these activities will be considered for removal
      Returns:
      The number of objects deleted
      Throws:
      ServerException - if a problem occurred on the server-side, or an unsupported bOTypeName was provided, or if this method was called from a non-local session
    • fixupWhereClause

      public String fixupWhereClause(com.primavera.bo.defs.BusinessObjectDef boDef, String whereClause) throws WhereClauseException
      Verifies and translates column names from integration to logical.
      Parameters:
      boDef - which BO we are handling
      whereClause - User supplied where clause
      Returns:
      String the fixup string which can be used to call.
      Throws:
      WhereClauseException - if a problem occurred while parsing the where clause
    • loadSafetyDate

      public abstract Timestamp loadSafetyDate() throws ServerException, NetworkException
      Loads the safety date from the database. The safety date can be used to identify business objects that have been updated since the last load of the safety date.
      Returns:
      the safety date
      Throws:
      ServerException - when a Server exception occurs
      NetworkException - when a Network exception occurs
    • getUCMDocument

      public abstract byte[] getUCMDocument(String uuid, String version) throws ServerException, RemoteException, Exception
      Gets the byte array of UCM document.
      Parameters:
      uuid - the UCM ID of a document.
      version - the version of the document.
      Returns:
      the contents of a content repository document.
      Throws:
      Exception - if a problem occurred.
      ServerException
      RemoteException
    • getUCMVersionHistory

      public abstract DocumentVersion[] getUCMVersionHistory(String uuid) throws ServerException, RemoteException, Exception
      Gets all the versions of a content repository document.
      Parameters:
      uuid - the ID of a content repository document.
      Returns:
      all versions of a content repository document.
      Throws:
      Exception - if a problem occurred.
      ServerException
      RemoteException
    • getUCMDocumentsRecentVersion

      public abstract DocumentDetail[] getUCMDocumentsRecentVersion(List<String> uuids) throws Exception
      Gets the most recent version of each document.
      Parameters:
      uuids - the unique ID of content repository documents.
      Returns:
      the most recent version of content repository documents.
      Throws:
      Exception - if a problem occurred.
    • getUCMDocumentDetail

      public abstract DocumentDetail getUCMDocumentDetail(String uuid) throws Exception
      Gets the most recent version of a content repository document.
      Parameters:
      uuid - the unique ID of a content repository document.
      Returns:
      the recent version a content repository document.
      Throws:
      Exception - if a problem occurred.
    • setBatchFailOnFirstFlag

      public void setBatchFailOnFirstFlag(boolean fail)
      Sets the flag that indicates whether batch creates and updates should be aborted when the first exception occurs (the default behavior), or whether the entire batch should be processed and then all business rule exceptions reported in a single BatchException.
      Parameters:
      fail - true to fail on first, false otherwise
    • setExportOption

      public void setExportOption(String exportOption)
    • setIpmDarExportOption

      public void setIpmDarExportOption(Boolean ipmdarExport)
    • getBatchFailOnFirstFlag

      public boolean getBatchFailOnFirstFlag()
      Gets the flag that indicates whether batch creates and updates should be aborted when the first exception occurs (the default behavior), or whether the entire batch should be processed and then all business rule exceptions reported in a single BatchException.
      Returns:
      boolean true for fail on first, false otherwise
    • importProjects

      public com.primavera.integration.apiapps.ImportExportProjectsOutput importProjects(com.primavera.integration.apiapps.ImportExportProjectsInput input) throws Exception
      Throws:
      Exception
    • exportProjects

      public com.primavera.integration.apiapps.ImportExportProjectsOutput exportProjects(com.primavera.integration.apiapps.ImportExportProjectsInput input) throws Exception
      Throws:
      Exception
    • getSessionId

      public String getSessionId()
    • close

      public void close()
      Allow try-with-resources blocks to autoclose a session by logging out
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • populateUPKLIST

      public abstract int populateUPKLIST(ObjectId epsObjectId) throws ServerException, NetworkException
      Throws:
      ServerException
      NetworkException
    • getTemplateMap

      public abstract Map<Object,Object> getTemplateMap(String templateId, String userId) throws ServerException, NetworkException
      Throws:
      ServerException
      NetworkException
    • getAdminConfigSetting

      public abstract Object getAdminConfigSetting(String name, Class type) throws ServerException, NetworkException
      Throws:
      ServerException
      NetworkException
    • updateLicense

      public abstract void updateLicense() throws ServerException, NetworkException
      Throws:
      ServerException
      NetworkException