# Script to append Read Audit Queue to Logger Clinical Module

#-- getting the properties.py file here
execfile("properties.py")
#==========================================================================
# open the domain.
#==========================================================================
readDomain(props.getProperty("cds.appserver.domaindir"))

#==========================================================================
# Create  JMS Queue function
#==========================================================================
def createJMSQueue(QueueName,SubdeploymentName,ModuleName,needErrorQueue,ErrorQueue):  
   cd('/')
   cd('JMSSystemResource/'+ModuleName+'/JmsResource/NO_NAME_0')
   myq=create(QueueName,'Queue')
   cd('Queues/'+QueueName)
   QueueJNDIName="jms/cds/"+QueueName
   set('JNDIName',QueueJNDIName)
   myq.setSubDeploymentName(SubdeploymentName)
   # The subdeployment was getting assigned to "cds.appserver.domaindir" after running the update script
   # The explicit assign statement retains the existing assignment
   for i in range(len(jmsSubdeployment)/3):
      assign('JMSSystemResource.SubDeployment',jmsSubdeployment[i*3], 'Target', jmsSubdeployment[(i*3)+2])
   if(needErrorQueue != "noError"):
      DeliveryFailureParams=create('DeliveryFailureParams','DeliveryFailureParams')
      DeliveryFailureParams.setExpirationPolicy('Redirect')
      DeliveryFailureParams.setRedeliveryLimit(4)
      DeliveryFailureParams.setErrorDestination(ErrorQueue)
   return myq

createJMSQueue("ReadAuditQueue","LoggerSubdeployment","LoggerModule","noError","DummyValue")

updateDomain()
closeDomain()