/** * Creates new SyncAttribute instances out of the properties of an entity. The newly created * instances are added to syncAttributeList. * * <p>SyncLSyncAttributeink is a JAXB Xml class generated out of verinice import and export XML * schema files: sernet/verinice/service/sync sync.xsd data.xsd mapping.xsd * * @param entity * @param syncAttributeList * @param typeId * @param huiTypeFactory */ public static void transform( Entity entity, List<SyncAttribute> syncAttributeList, String typeId, HUITypeFactory huiTypeFactory, ExportReferenceTypes exportReferenceTypes) { Map<String, PropertyList> properties = entity.getTypedPropertyLists(); for (String propertyTypeId : properties.keySet()) { PropertyType propertyType = huiTypeFactory.getPropertyType(typeId, propertyTypeId); if (propertyType == null) { LOG.warn("Property type not found in SNCA.xml: " + propertyTypeId + ", typeId: " + typeId); } if (propertyType == null || propertyType.isReportable()) { SyncAttribute syncAttribute = new SyncAttribute(); // Add <syncAttribute> to this <syncObject>: syncAttribute.setName(propertyTypeId); // transform dbid to uuid for the export if (isReference(propertyType)) { PropertyList propertyList = entity.getProperties(propertyTypeId); exportReferenceTypes.mapEntityDatabaseId2ExtId(syncAttribute, propertyList); } else { entity.exportProperties(propertyTypeId, syncAttribute.getValue()); } if (!syncAttribute.getValue().isEmpty()) { syncAttributeList.add(syncAttribute); } } } }
public static void hydrateEntity(IBaseDao dao, Entity entity) { if (dao == null) { Logger.getLogger(HydratorUtil.class).error("Missing DAO, cannot hydrate."); return; } if (entity == null) return; Map<String, PropertyList> lists = entity.getTypedPropertyLists(); Set<Entry<String, PropertyList>> entrySet = lists.entrySet(); for (Entry<String, PropertyList> entry : entrySet) { PropertyList list = entry.getValue(); List<Property> propertyList = list.getProperties(); dao.initialize(propertyList); // set the parent in the property since it is not mapped by hibernate anymore for (Property property : propertyList) { property.setParent(entity); } } }