Importing Objects with Import Rule Sets
You use import rule sets to customize your imports. Import rule sets allow you to organize the flow of processes between Development, Quality Assurance and Production systems. You can adapt default values of parameters, for example, to the target system. Import rule set actions allow you to further customize the objects during the import process with RedwoodScript
note
The Promotion Module requires the Module.ImportExport license key
Import Rules
Import rule sets can hold one or more import rules. When you create an import, you may specify an import rule set according to which Parameters, like INSTANCE
, CLIENT
, or USERNAME
for SAP process definitions, can be adjusted to the new system with overrides.
Actions on import rule sets allow you to specify RedwoodScript code to be executed against the imported objects before they are written to the database. The code can be specified on the Actions tab and make use of the classes that you have stored in a library.
note
You should not persist the session in import rule set actions, as this is done for you at a later stage.
Procedure
Creating Import Rule Sets
- Navigate to "Promotion > Import Rule Sets".
- Choose New Import Rule Set from the context-menu.
- Fill in the details and choose the Import Rules Tab.
- Choose Add to create a new import rule and fill in the details.
- Choose Save & Close.
Using Import Rule Sets
- Navigate to "Promotion > Imports".
- Choose Import from the context-menu.
- Fill in the details and specify an import rule set to narrow down the imported objects.
- Choose Save & Close.
Examples
Pre Import - Hold a Queue Prior to the Import
You wish to prepare the environment for the objects to import, part of that requires you to hold a queue.
- Navigate to Applications.
- Choose New Application from the context-menu, select partition
GLOBAL
, and fillExample
into the Name field. - Choose Save & Close.
- Navigate to "Promotion > Import Rule Sets".
- Choose New Import Rule Set from the context-menu.
- Fill in a name and choose the Import Action tab.
- Choose Pre Import and fill the code below into the Source field.
- Choose Save & Close.
{
Partition p = jcsSession.getPartitionByName("REDWOOD");
Queue q = jcsSession.getQueueByName(p, "MSLN_Queue");
q.hold();
}
Sample code to that holds queue REDWOOD.MSLN_Queue
prior to the import.
Post Import - Using import rules to change objects during import
A CAR archive containing multiple process definitions are to be imported, these process definitions all have a parameter named SAP_SYSTEMS
that needs to get a new default value. The default value in the car file is Q2A and should be replaced with PR2 to match the new system. The parameter CLIENT
also needs to change from 200 to 800.
- Navigate to "Promotion > Import Rule Sets".
- Choose New Import Rule Set from the context-menu.
- Fill in a name and choose the Import Rules tab.
- Choose New Import Rule Set to create a new import rule and fill the details below into the Name and Object Type fields.
- Choose Add next to Parameter Matches for the Matching field and fill in the details below, do the same for Replaces.
- Perform steps 3 to 5 for the CLIENT parameter.
- Choose Save & Close.
Values
SAP_SYSTEMS
parameter:
Field | Value |
---|---|
Name | Q2A_TO_PR2 |
Object Type | Job Definition |
Matching - Name | SAP_SYSTEMS |
Matching - Default Expression | Q2A |
Replaces - Name | SAP_SYSTEMS |
Replaces - Default Expression | PR2 |
CLIENT
parameter:
Field | Value |
---|---|
Name | 200_TO_800 |
Object Type | Job Definition |
Matching - Name | CLIENT |
Matching - Default Expression | 200 |
Replaces - Name | CLIENT |
Replaces - Default Expression | 800 |
Post Import - Using RedwoodScript code to change objects on import
All referenced objects that are not in the CAR file must be in the target system, if you have unresolved references, for example, you promote from Test to Production and an application referenced by objects in the CAR file is neither in the CAR file nor in the target system, you must fix unresolved references. See Using RedwoodScript to repair missing references below.
- Navigate to Applications.
- Choose New Application from the context-menu, select partition
GLOBAL
, and fillExample
into the Name field. - Choose Save & Close.
- Navigate to "Promotion > Import Rule Sets".
- Choose New Import Rule Set from the context-menu.
- Fill in a name and choose the Import Action tab.
- Choose Post Import and fill the code below into the Source field.
- Choose Save & Close.
{
Partition part = jcsSession.getPartitionByName("GLOBAL");
Application application = jcsSession.getApplicationByName(part, "Example");
for (Object o : jcsImportRuleSet.getObjects())
{
if (o instanceof ApplicationObject)
{
((ApplicationObject) o).setParentApplication(application);
}
}
}
Sample code to set the application or parent application to the `Example` application
Post Import - Using RedwoodScript to repair missing references
One or more objects in the CAR file reference objects that are neither in the CAR file nor in the target system, the objects have to be updated via the UnresolvedObjects Map.
- Navigate to Applications.
- If the application Example does not exist, choose New Application from the context-menu, select partition
GLOBAL
, end fillExample
into the Name field. - Choose Save & Close.
- Create an application named MSLN_Temporary in the
GLOBAL
partition. - Navigate to "Promotion > Import Rule Sets".
- Choose New Import Rule Set from the context-menu.
- Fill in a name and choose the Import Action tab.
- Choose Post Import and fill the code below into the Source field.
- Choose Save & Close.
- Create a process definition of type RedwoodScript named RS_MSLN_TestImport with
{}
as the Source and MSLN_Temporary as application. - Navigate to "Definitions > Processes" and export the previously created process definition (without related objects ).
- Delete the process definition and submit System_ProcessKeepClauses to run now.
- Navigate to Applications and delete application MSLN_Temporary.
- Submit an import with the previously created ImportRuleSet and select the previously exported car file.
- Navigate to "Definitions > Processes" and locate the process definition, notice the application is set to Example.
//@pragma:Unresolved
import com.redwood.scheduler.api.model.Application;
import com.redwood.scheduler.api.scripting.variables.ImportActionUnresolvedObject;
import java.util.Map;
{
Map<Long,ImportActionUnresolvedObject> unresolved = jcsImportRuleSet.getUnresolvedObjects();
Partition part = jcsSession.getPartitionByName("GLOBAL");
Application exampleApp = jcsSession.getApplicationByName(part, "Example");
unresolved.forEach((k, v)->
{
jcsOutLog.info("type: " + v.getObjectType());
jcsOutLog.info("path: " + v.getPath());
if (exampleApp != null
&& Application.OBJECT_TYPE.equals(v.getObjectType())
&& "GLOBAL.MSLN_Temporary.$2".equals(v.getPath())) //Check the application path in the source system, ensure you specify the correct path here
{
v.replaceWith(exampleApp);
}
});
}
Replace all references to application `GLOBAL.MSLN_Temporary` with application `GLOBAL.Example`.
tip
If your import action does not replace all unresolved objects, a RuntimeException
will be thrown with the number of unresolved references. Submit the import without import action to get a list of unresolved references.
Post Persist - Release a Queue
- Navigate to "Promotion > Import Rule Sets".
- Choose New Import Rule Set from the context-menu.
- Fill in a name and choose the Import Action tab.
- Choose Post Persist and fill the code below into the Source field.
- Choose Save & Close.
{
Partition p = jcsSession.getPartitionByName("REDWOOD");
Queue q = jcsSession.getQueueByName(p, "MSLN_Queue");
q.release();
}
Release queue REDWOOD.MSLN_Queue
after the objects have been imported.
Post Persist - Submit a Process after Import
You wish to submit a process after import to cleanup or prepare the environment for the newly imported objects. The process definition can have been imported in the import where this runs.
- Navigate to "Promotion > Import Rule Sets".
- Choose New Import Rule Set from the context-menu.
- Fill in a name and choose the Import Action tab.
- Choose Post Persist and fill the code below into the Source field.
- Choose Save & Close.
//Get imported process Definition
Partition p = jcsSession.getPartitionByName("REDWOOD");
JobDefinition jd = jcsSession.getJobDefinitionByName(p, "MSLN_Installer");
Job j = jd.prepare();
Submit a process from a Post Persist import action to cleanup after the import has completed.
See Also
- Customizing Imports with ImportRuleSets
- Importing Objects
- Importing Redwood Server Objects with Imports
- Migrating Objects with the Promotion Module
- Privileges Required to use ImportRuleDefinition
- Privileges Required to use ImportRuleSets
- Privileges Required to use ImportSources
- Export Rule Sets
- Creating Export Rule Sets
- Exporting Redwood Server Objects
- Promoting Objects with Remote Systems
ImportRuleSet import rule set