Skip to content

Commit

Permalink
Merge branch 'master' into modfqmmgr-442
Browse files Browse the repository at this point in the history
  • Loading branch information
ncovercash authored Aug 29, 2024
2 parents a6b97a2 + 7d6dba1 commit 2e2624c
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;
import org.folio.fqm.migration.strategies.V0POCMigration;
import org.folio.fqm.migration.strategies.V1ModeOfIssuanceConsolidation;
import org.folio.fqm.migration.strategies.V2ResourceTypeConsolidation;
import org.springframework.stereotype.Component;

@Component
Expand All @@ -11,7 +12,8 @@ public class MigrationStrategyRepository {
// prevent re-initialization on each call
private static final List<MigrationStrategy> MIGRATION_STRATEGIES = List.of(
new V0POCMigration(),
new V1ModeOfIssuanceConsolidation()
new V1ModeOfIssuanceConsolidation(),
new V2ResourceTypeConsolidation()
);

public List<MigrationStrategy> getMigrationStrategies() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class V1ModeOfIssuanceConsolidation extends AbstractSimpleMigrationStrate

@Override
public String getLabel() {
return "V1 -> V2 Removed simple_mode_of_issuance";
return "V1 -> V2 Removed simple_mode_of_issuance (MODFQMMGR-427)";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package org.folio.fqm.migration.strategies;

import java.util.Map;
import java.util.UUID;
import java.util.function.BiFunction;
import java.util.function.Function;
import org.folio.fqm.migration.AbstractSimpleMigrationStrategy;
import org.folio.fqm.migration.warnings.EntityTypeWarning;
import org.folio.fqm.migration.warnings.FieldWarning;

/**
* Version 2 -> 3, decouples simple_mode_of_issuance entity type from composite_instances
* @see https://folio-org.atlassian.net/browse/MODFQMMGR-429
*/
public class V2ResourceTypeConsolidation extends AbstractSimpleMigrationStrategy {

public static final UUID COMPOSITE_INSTANCES = UUID.fromString("6b08439b-4f8e-4468-8046-ea620f5cfb74");

@Override
public String getLabel() {
return "V2 -> V3 Exposing resource_type directly in composite_instances (MODFQMMGR-429)";
}

@Override
public String getSourceVersion() {
return "2";
}

@Override
public String getTargetVersion() {
return "3";
}

@Override
public Map<UUID, UUID> getEntityTypeChanges() {
return Map.of();
}

@Override
public Map<UUID, Map<String, String>> getFieldChanges() {
return Map.ofEntries(
Map.entry(
COMPOSITE_INSTANCES,
Map.ofEntries(
Map.entry("instance_type.id", "instance.instance_type_id"),
Map.entry("instance_type.name", "instance.instance_type_name")
)
)
);
}

@Override
public Map<UUID, Function<String, EntityTypeWarning>> getEntityTypeWarnings() {
return Map.of();
}

@Override
public Map<UUID, Map<String, BiFunction<String, String, FieldWarning>>> getFieldWarnings() {
return Map.of();
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/folio/fqm/service/MigrationService.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class MigrationService {

public static final UUID REMOVED_ENTITY_TYPE_ID = UUID.fromString("deadbeef-dead-dead-dead-deaddeadbeef");

protected static final String CURRENT_VERSION = "2";
protected static final String CURRENT_VERSION = "3";

// TODO: replace this with current version in the future?
protected static final String DEFAULT_VERSION = "0";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@
condition: ":this.id = (:that.jsonb ->> 'statusId')::uuid",
},
},
{
alias: 'instance_type',
type: 'entity-type',
id: 'af44e2e0-12e0-4eec-b80d-49feb33a866c', // simple_instance_type
join: {
type: 'left join',
joinTo: 'instance.inst',
condition: ':this.id = :that.instanceTypeId',
},
},
],
defaultSort: [
{
Expand Down
32 changes: 31 additions & 1 deletion src/main/resources/entity-types/inventory/simple_instance.json5
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@
condition: ':this.id = :that.modeOfIssuanceId',
},
},
{
type: 'db',
alias: 'instance_type',
target: 'src_inventory_instance_type',
join: {
type: 'left join',
joinTo: 'inst',
condition: ':this.id = :that.instanceTypeId',
},
},
],
requiredPermissions: [
'inventory-storage.instances.item.get',
Expand Down Expand Up @@ -110,10 +120,30 @@
},
isIdColumn: false,
queryable: true,
essential: true,
essential: false,
visibleByDefault: false,
valueGetter: ':sourceAlias.instancetypeid',
},
{
name: 'instance_type_name',
sourceAlias: 'instance_type',
dataType: {
dataType: 'stringType',
},
isIdColumn: false,
queryable: true,
visibleByDefault: true,
essential: true,
valueGetter: ":sourceAlias.jsonb->>'name'",
filterValueGetter: "lower(\
${tenant_id}_mod_inventory_storage.f_unaccent (:sourceAlias.jsonb->>'name'::text)\
)",
valueFunction: 'lower(${tenant_id}_mod_inventory_storage.f_unaccent (:value))',
source: {
entityTypeId: 'af44e2e0-12e0-4eec-b80d-49feb33a866c',
columnName: 'name',
},
},
{
name: 'mode_of_issuance_id',
sourceAlias: 'inst',
Expand Down
3 changes: 2 additions & 1 deletion translations/mod-fqm-manager/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,8 @@
"entityType.simple_instance.identifiers.value._qualified": "Identifiers value",
"entityType.simple_instance.index_title": "Index title",
"entityType.simple_instance.instance_format_ids": "Instance format UUIDs",
"entityType.simple_instance.instance_type_id": "Instance type UUID",
"entityType.simple_instance.instance_type_id": "Resource type UUID",
"entityType.simple_instance.instance_type_name": "Resource type",
"entityType.simple_instance.jsonb": "JSONB",
"entityType.simple_instance.languages": "Languages",
"entityType.simple_instance.match_key": "Match key",
Expand Down

0 comments on commit 2e2624c

Please sign in to comment.