diff --git a/pom.xml b/pom.xml index 5d0c072..b067b88 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ ch.sbb.polarion.extensions ch.sbb.polarion.extension.generic - 7.2.0 + 7.3.1 ch.sbb.polarion.extension.excel-importer diff --git a/src/main/java/ch/sbb/polarion/extension/excel_importer/EnumUtils.java b/src/main/java/ch/sbb/polarion/extension/excel_importer/EnumUtils.java deleted file mode 100644 index fd4c28e..0000000 --- a/src/main/java/ch/sbb/polarion/extension/excel_importer/EnumUtils.java +++ /dev/null @@ -1,19 +0,0 @@ -package ch.sbb.polarion.extension.excel_importer; - -import com.polarion.alm.tracker.model.IPriorityOpt; -import com.polarion.platform.persistence.IEnumOption; -import lombok.experimental.UtilityClass; - -import java.util.Optional; - -@UtilityClass -public class EnumUtils { - - /** - * For some options (e.g. 'priority') method getId() returns weird float-like containing strings ("90.0", "50.0" etc.) instead if proper ID. - * Was noticed that proper ID can be accessed from option properties by special key 'standardOptionId'. - */ - public String getEnumId(IEnumOption option) { - return Optional.ofNullable(option.getProperty(IPriorityOpt.PROPERTY_KEY_STD_OPTION_ID)).orElse(option.getId()); - } -} diff --git a/src/main/java/ch/sbb/polarion/extension/excel_importer/service/ImportService.java b/src/main/java/ch/sbb/polarion/extension/excel_importer/service/ImportService.java index 8334a31..ffd90a8 100644 --- a/src/main/java/ch/sbb/polarion/extension/excel_importer/service/ImportService.java +++ b/src/main/java/ch/sbb/polarion/extension/excel_importer/service/ImportService.java @@ -3,6 +3,7 @@ import ch.sbb.polarion.extension.excel_importer.settings.ExcelSheetMappingSettingsModel; import ch.sbb.polarion.extension.generic.fields.FieldType; import ch.sbb.polarion.extension.generic.fields.model.FieldMetadata; +import ch.sbb.polarion.extension.generic.util.OptionsMappingUtils; import com.polarion.alm.projects.model.IUniqueObject; import com.polarion.alm.shared.api.transaction.TransactionalExecutor; import com.polarion.alm.tracker.model.ITrackerProject; @@ -113,6 +114,9 @@ private String getIdentifierValue(Map recordMap, String columnLe private void fillWorkItemFields(IWorkItem workItem, Map mappingRecord, ExcelSheetMappingSettingsModel model, String linkColumnId) { mappingRecord.forEach((columnId, value) -> { String fieldId = model.getColumnsMapping().get(columnId); + // we need to know possible mapped value asap because some types (at least boolean) need it to check value for modification + String mappedOption = OptionsMappingUtils.getMappedOptionKey(fieldId, value, model.getEnumsMapping()); + value = mappedOption != null ? mappedOption : value; Set fieldMetadataSet = polarionServiceExt.getWorkItemsFields(workItem.getProjectId(), workItem.getType() == null ? "" : workItem.getType().getId()); // The linkColumn field's value can't change, therefore it doesn't need to be overwritten. // However, it must be saved to the newly created work item otherwise sequential imports will produce several objects. diff --git a/src/main/java/ch/sbb/polarion/extension/excel_importer/service/PolarionServiceExt.java b/src/main/java/ch/sbb/polarion/extension/excel_importer/service/PolarionServiceExt.java index cf62106..1ccc286 100644 --- a/src/main/java/ch/sbb/polarion/extension/excel_importer/service/PolarionServiceExt.java +++ b/src/main/java/ch/sbb/polarion/extension/excel_importer/service/PolarionServiceExt.java @@ -1,6 +1,7 @@ package ch.sbb.polarion.extension.excel_importer.service; import ch.sbb.polarion.extension.generic.fields.model.FieldMetadata; +import ch.sbb.polarion.extension.generic.fields.model.Option; import com.polarion.alm.projects.IProjectService; import com.polarion.alm.tracker.ITrackerService; import com.polarion.alm.tracker.model.ITrackerProject; @@ -12,6 +13,7 @@ import com.polarion.platform.security.ISecurityService; import com.polarion.platform.service.repository.IRepositoryService; import com.polarion.subterra.base.data.identification.IContextId; +import com.polarion.subterra.base.data.model.internal.PrimitiveType; import org.jetbrains.annotations.NotNull; import java.util.List; @@ -21,6 +23,8 @@ public class PolarionServiceExt extends ch.sbb.polarion.extension.generic.service.PolarionService { + private static final Set