Hi,
I’m building a JAVA application to bulk load assets (custom asset type) from CSV file to Centrasite 9.5 via JAXR.
It works fine except that only the last asset retains the association (relationship), I think it is because it’s the last relationship created before disconnection from Centrasite.
The code I’m using is below, can someone give an hint on how to solve this without having to close the connection for each asset?
public static void loadListOfServices() throws IOException {
List<CustomService> services = readFromCSV();
try
{
connectToCentrasite();
for(CustomService item : services){
createCustomService(item.getBusinessName(), item.getDescription(), item.getVersion(), item.getRationale(), item.getPhysicalName(), item.getProject(), item.getProjectRelationType());
}
}
catch(JAXRException e)
{
LOGGER.error(e);
} finally {
disconnectFromCentrasite();
}
}
public static void createCustomService(String customServiceName, String customServiceDescription, String customVersionValue, String customRationaleValue,
String customPhysicalName, String projectName, String relationType) throws JAXRException{
RegistryEntry customService = centrasiteService.createUserObject(customServiceName, customServiceDescription, centrasiteService.getCustomServiceType());
centrasiteService.addSlotToObject(customService, "Rationale", customRationaleValue , CentraSiteSlotType.XS_STRING);
centrasiteService.addSlotToObject(customService, "Version", customVersionValue, CentraSiteSlotType.XS_STRING);
centrasiteService.addSlotToObject(customService, "PhysicalServices", customPhysicalName, CentraSiteSlotType.XS_STRING);
RegistryEntry customProjectToRelate = centrasiteService.findUserObject(projectName, centrasiteService.getCustomProjectType());
RegistryEntry relatedObject = centrasiteService.createRelationshipAttribute(customProjectToRelate, customService, centrasiteService.getCustomProjectType(), relationType, true);
centrasiteService.saveObject(relatedObject);
centrasiteService.saveObject(customService);
centrasiteService.saveObject(customProjectToRelate);
}