@Override public VmTemplate mapRow(ResultSet rs, int rowNum) throws SQLException { final VmTemplate entity = new VmTemplate(); map(rs, entity); entity.setId(getGuidDefaultEmpty(rs, "vmt_guid")); entity.setChildCount(rs.getInt("child_count")); entity.setName(rs.getString("name")); entity.setClusterId(getGuid(rs, "cluster_id")); entity.setStatus(VmTemplateStatus.forValue(rs.getInt("status"))); entity.setClusterName(rs.getString("cluster_name")); entity.setClusterCompatibilityVersion(new VersionRowMapper("cluster_compatibility_version").mapRow(rs, rowNum)); entity.setStoragePoolId(getGuid(rs, "storage_pool_id")); entity.setStoragePoolName(rs.getString("storage_pool_name")); entity.setQuotaName(rs.getString("quota_name")); entity.setQuotaEnforcementType(QuotaEnforcementTypeEnum.forValue(rs.getInt("quota_enforcement_type"))); entity.setDisabled(rs.getBoolean("is_disabled")); entity.setTrustedService(rs.getBoolean("trusted_service")); entity.setTemplateType(VmEntityType.valueOf(rs.getString("entity_type"))); entity.setClusterArch(ArchitectureType.forValue(rs.getInt("architecture"))); entity.setBaseTemplateId(getGuidDefaultEmpty(rs, "base_template_id")); entity.setTemplateVersionNumber(rs.getInt("template_version_number")); entity.setTemplateVersionName(rs.getString("template_version_name")); return entity; } }
@Override protected void readGeneralData(XmlNode content) { super.readGeneralData(content); consumeReadProperty(content, IS_DISABLED, val -> template.setDisabled(Boolean.parseBoolean(val))); consumeReadProperty(content, TRUSTED_SERVICE, val -> template.setTrustedService(Boolean.parseBoolean(val))); consumeReadProperty(content, TEMPLATE_TYPE, val -> template.setTemplateType(VmEntityType.valueOf(val))); consumeReadProperty(content, BASE_TEMPLATE_ID, val -> template.setBaseTemplateId(Guid.createGuidFromString(val)), // in case base template is missing, we assume it is a base template () -> template.setBaseTemplateId(template.getId())); consumeReadProperty(content, TEMPLATE_VERSION_NUMBER, val -> template.setTemplateVersionNumber(Integer.parseInt(val))); consumeReadProperty(content, TEMPLATE_VERSION_NAME, val -> template.setTemplateVersionName(val)); }
public VmTemplate(VmTemplate template) { super(template); diskTemplateMap = new HashMap<>(); diskImageMap = new HashMap<>(); setChildCount(template.getChildCount()); setStatus(template.getStatus()); setTemplateType(template.getTemplateType()); setBaseTemplateId(template.getBaseTemplateId()); setTemplateVersionName(template.getTemplateVersionName()); setTemplateVersionNumber(template.getTemplateVersionNumber()); setDisabled(template.isDisabled()); setDescription(this.getDescription()); }
@Override protected void readGeneralData(XmlNode content) { super.readGeneralData(content); consumeReadProperty(content, TEMPLATE_ID, val -> _vmTemplate.setId(new Guid(val))); consumeReadProperty(content, IS_DISABLED, val -> _vmTemplate.setDisabled(Boolean.parseBoolean(val))); consumeReadProperty(content, TRUSTED_SERVICE, val -> _vmTemplate.setTrustedService(Boolean.parseBoolean(val))); consumeReadProperty(content, TEMPLATE_TYPE, val -> _vmTemplate.setTemplateType(VmEntityType.valueOf(val))); consumeReadProperty(content, BASE_TEMPLATE_ID, val -> _vmTemplate.setBaseTemplateId(Guid.createGuidFromString(val)), () -> { // in case base template is missing, we assume it is a base template _vmTemplate.setBaseTemplateId(_vmTemplate.getId()); }); consumeReadProperty(content, TEMPLATE_VERSION_NUMBER, val -> _vmTemplate.setTemplateVersionNumber(Integer.parseInt(val))); consumeReadProperty(content, TEMPLATE_VERSION_NAME, val -> _vmTemplate.setTemplateVersionName(val)); consumeReadProperty(content, AUTO_STARTUP, val -> _vmTemplate.setAutoStartup(Boolean.parseBoolean(val))); }