Class Session
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
DistributedSession,LocalSession
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringBatch over-ride system property.static final intThe default where clause bind parameter limitstatic final intThe default batch size for loading business objects in Local Mode.static final intThe default batch size for loading business objects in Remote Mode.static final intThe maximum where clause bind parameter limitstatic final intThe maximum batch size for loading the business objects.static final intThe minimum where clause bind parameter limitstatic final intThe minimum batch size for loading the business objects. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Allow try-with-resources blocks to autoclose a session by logging outcom.primavera.integration.apiapps.ImportExportProjectsOutputexportProjects(com.primavera.integration.apiapps.ImportExportProjectsInput input) fixupWhereClause(com.primavera.bo.defs.BusinessObjectDef boDef, String whereClause) Verifies and translates column names from integration to logical.abstract ObjectgetAdminConfigSetting(String name, Class type) booleanGets 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.intRetrieves the current limit on bind parametersintRetrieves the current batch size for loading business objects.Retrieves the database encoding this session is logged intoRetrieves the database instance ID used to login and establish this session.static DatabaseInstance[]getDatabaseInstances(String sUrl) Retrieves all database instances supported by the server.Retrieves the name of the database this session is logged into.intRetrieves the database type this session is logged into.Retrieves the database type this session is logged into.Retrieves the URL of the database this session is logged into.Gets theEnterpriseLoadManagerfor this session.Gets theGlobalObjectManagerfor this session.Gets theJobManagerfor this session.getTemplateMap(String templateId, String userId) abstract byte[]getUCMDocument(String uuid, String version) Gets the byte array of UCM document.abstract DocumentDetailgetUCMDocumentDetail(String uuid) Gets the most recent version of a content repository document.abstract DocumentDetail[]getUCMDocumentsRecentVersion(List<String> uuids) Gets the most recent version of each document.abstract DocumentVersion[]getUCMVersionHistory(String uuid) Gets all the versions of a content repository document.Retrieves the name of theUserwho is logged in using this Session instance.abstract ObjectIdabstract ObjectIdReturns andObjectIdrepresentation of the usession idcom.primavera.integration.apiapps.ImportExportProjectsOutputimportProjects(com.primavera.integration.apiapps.ImportExportProjectsInput input) static booleanIndicates whether Local Mode is available.static booleanIndicates whether Remote Mode is available.abstract booleanisValid()Verifies if the session is valid.abstract TimestampLoads the safety date from the database.static Sessionstatic SessionLogs in and obtains a Session object.abstract voidlogout()Notifies the server that this session is no longer needed and releases any resources allocated for this session.<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) abstract intpopulateUPKLIST(ObjectId epsObjectId) intremoveDeletedObjectsFromBaseline(String boTypeName, ObjectId origProjectId, ObjectId blProjectId, Collection<String> parentActivityIdsToConsider) Removes certain child objects from a baseline which do not exist in the original project This method is only supported for local sessions.voidsetBatchFailOnFirstFlag(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.voidsetBindParameterLimitOnLoad(int iBindParameterLimit) Set the new bind parameter limit for loading business objects.voidsetBusinessObjectBatchSize(int iBatchSize) Set the new batch size for loading business objects.voidsetExportOption(String exportOption) voidsetIpmDarExportOption(Boolean ipmdarExport) abstract void
-
Field Details
-
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_SIZEThe 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_SIZEThe maximum batch size for loading the business objects.- See Also:
-
MIN_BUSINESS_OBJECT_BATCH_SIZE
public static final int MIN_BUSINESS_OBJECT_BATCH_SIZEThe 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_LOADThe maximum where clause bind parameter limit- See Also:
-
MIN_BIND_PARAM_LIMIT_ON_LOAD
public static final int MIN_BIND_PARAM_LIMIT_ON_LOADThe minimum where clause bind parameter limit- See Also:
-
DEFAULT_BIND_PARAM_LIMIT_ON_LOAD
public static final int DEFAULT_BIND_PARAM_LIMIT_ON_LOADThe default where clause bind parameter limit- See Also:
-
DEFAULT_REMOTE_BATCH_SIZE
public static final int DEFAULT_REMOTE_BATCH_SIZEThe 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 theisRemoteModeAvailableandisLocalModeAvailablemethods 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 theRMIURLclass to create the URL.- Returns:
- DatabaseInstance[] array of DatabaseInstance objects representing available databases
- Throws:
ServerException- if a problem occurred on the server-sideClientException- if a problem occurred on the client-sideNetworkException- 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 -
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 useisRemoteModeAvailableandisLocalModeAvailablemethods to check if the specific mode is available.- Parameters:
sUrl- the location of the server, or null for Local Mode. Use theRMIURLclass to create the URL.sDbId- the database instance idsUserName- the user namesPassword- the password- Returns:
- Session session object
- Throws:
ServerException- if a problem occurred on the server-sideClientException- if a problem occurred on the client-sideNetworkException- 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
Verifies if the session is valid.- Returns:
- true if session is valid
- Throws:
NetworkException
-
getUserObjectId
- Returns:
- ObjectId the user object id
- Throws:
ServerException- if a problem occurred on the server-sideNetworkException- if a problem occurred in the network layer
-
getGlobalObjectManager
Gets theGlobalObjectManagerfor this session.- Returns:
- GlobalObjectManager the global object manager
-
getEnterpriseLoadManager
Gets theEnterpriseLoadManagerfor this session.- Returns:
- EnterpriseLoadManager the enterprise load manager
-
getJobManager
Gets theJobManagerfor this session.- Returns:
- JobManager the job manager
-
getDatabaseInstanceId
Retrieves the database instance ID used to login and establish this session.- Returns:
- String the current database instance ID
-
getUserName
Retrieves the name of theUserwho is logged in using this Session instance.- Returns:
- String the current user name
-
getDatabaseUrl
Retrieves the URL of the database this session is logged into.- Returns:
- database url, including machine name and port number.
-
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
Retrieves the database type this session is logged into.- Returns:
- database type
-
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
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
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
Returns andObjectIdrepresentation of the usession id- Returns:
- ObjectId USessionId
- Throws:
ServerException- if a problem occurred on the server-sideNetworkException
-
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 -
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 projectblProjectId- - ObjectId of the baseline projectparentActivityIdsToConsider- - 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 handlingwhereClause- 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
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 occursNetworkException- 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.ServerExceptionRemoteException
-
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.ServerExceptionRemoteException
-
getUCMDocumentsRecentVersion
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
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
-
setIpmDarExportOption
-
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
-
close
public void close()Allow try-with-resources blocks to autoclose a session by logging out- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
populateUPKLIST
- Throws:
ServerExceptionNetworkException
-
getTemplateMap
public abstract Map<Object,Object> getTemplateMap(String templateId, String userId) throws ServerException, NetworkException - Throws:
ServerExceptionNetworkException
-
getAdminConfigSetting
public abstract Object getAdminConfigSetting(String name, Class type) throws ServerException, NetworkException - Throws:
ServerExceptionNetworkException
-
updateLicense
- Throws:
ServerExceptionNetworkException
-