@SuppressWarnings("unchecked") private static Map<String, String> getCustomProperties(ResultSet rs) throws SQLException { return SerializationFactory.getDeserializer() .deserializeOrCreateNew(rs.getString("custom_properties"), LinkedHashMap.class); } }
@SuppressWarnings("unchecked") public static List<VmInitNetwork> jsonNetworksToList(String jsonNetworks) { return (List<VmInitNetwork>)new JsonObjectDeserializer().deserializeOrCreateNew(jsonNetworks, ArrayList.class); }
@Override protected RowMapper<ClusterPolicy> createEntityRowMapper() { return (rs, arg1) -> { ClusterPolicy clusterPolicy = new ClusterPolicy(); clusterPolicy.setId(getGuid(rs, "id")); clusterPolicy.setName(rs.getString("name")); clusterPolicy.setDescription(rs.getString("description")); clusterPolicy.setLocked(rs.getBoolean("is_locked")); clusterPolicy.setDefaultPolicy(rs.getBoolean("is_default")); clusterPolicy.setParameterMap(SerializationFactory.getDeserializer() .deserializeOrCreateNew(rs.getString("custom_properties"), LinkedHashMap.class)); return clusterPolicy; }; }
@Override protected RowMapper<PolicyUnit> createEntityRowMapper() { return (rs, arg1) -> { PolicyUnit policyUnit = new PolicyUnit(); policyUnit.setId(getGuid(rs, "id")); policyUnit.setName(rs.getString("name")); policyUnit.setInternal(rs.getBoolean("is_internal")); policyUnit.setPolicyUnitType(PolicyUnitType.forValue(rs.getInt("type"))); policyUnit.setDescription(rs.getString("description")); policyUnit.setParameterRegExMap(SerializationFactory.getDeserializer() .deserializeOrCreateNew(rs.getString("custom_properties_regex"), LinkedHashMap.class)); policyUnit.setEnabled(rs.getBoolean("enabled")); return policyUnit; }; }
protected void map(ResultSet rs, HostDevice device) throws SQLException{ device.setHostId(getGuid(rs, "host_id")); device.setDeviceName(rs.getString("device_name")); device.setParentDeviceName(rs.getString("parent_device_name")); device.setCapability(rs.getString("capability")); device.setIommuGroup((Integer) rs.getObject("iommu_group")); String mdevTypes = rs.getString("mdev_types"); if (mdevTypes != null && !mdevTypes.isEmpty()) { device.setMdevTypes(new HashSet<>(Arrays.asList(mdevTypes.split(",")))); } device.setProductName(rs.getString("product_name")); device.setProductId(rs.getString("product_id")); device.setVendorName(rs.getString("vendor_name")); device.setVendorId(rs.getString("vendor_id")); device.setParentPhysicalFunction(rs.getString("physfn")); device.setTotalVirtualFunctions((Integer) rs.getObject("total_vfs")); device.setNetworkInterfaceName(rs.getString("net_iface_name")); device.setAssignable(rs.getBoolean("is_assignable")); device.setAddress(SerializationFactory.getDeserializer() .deserializeOrCreateNew(rs.getString("address"), HashMap.class)); device.setVmId(getGuid(rs, "vm_id")); device.setDriver(rs.getString("driver")); } }
@Override @SuppressWarnings("unchecked") public T mapRow(ResultSet rs, int rowNum) throws SQLException { T entity = createVnicProfileEntity(); entity.setId(getGuid(rs, "id")); entity.setName(rs.getString("name")); entity.setNetworkId(getGuid(rs, "network_id")); entity.setNetworkQosId(getGuid(rs, "network_qos_id")); entity.setCustomProperties(SerializationFactory.getDeserializer() .deserializeOrCreateNew(rs.getString("custom_properties"), LinkedHashMap.class)); entity.setPortMirroring(rs.getBoolean("port_mirroring")); entity.setPassthrough(rs.getBoolean("passthrough")); entity.setMigratable(rs.getBoolean("migratable")); entity.setDescription(rs.getString("description")); entity.setNetworkFilterId(getGuid(rs, "network_filter_id")); return entity; }
@Override public HostDeviceView mapRow(ResultSet rs, int rowNum) throws SQLException { HostDeviceView device = new HostDeviceView(); map(rs, device); device.setConfiguredVmId(getGuid(rs, "configured_vm_id")); device.setAttachedVmNames(split(rs.getString("attached_vm_names"))); device.setRunningVmName(rs.getString("running_vm_name")); Map<String, Object> specParams = SerializationFactory.getDeserializer() .deserializeOrCreateNew(rs.getString("spec_params"), HashMap.class); device.setIommuPlaceholder(specParams != null && VmHostDevice.isIommuPlaceHolder(specParams)); return device; } }