Migration task updates

This commit is contained in:
jamesagnew 2020-06-10 09:56:49 -04:00
parent b8da4f0140
commit 05df4f0827
4 changed files with 63 additions and 32 deletions

View File

@ -237,7 +237,6 @@ public class JpaPackageCache extends BasePackageCacheManager implements IHapiPac
packageVersion.setFhirVersion(fhirVersion); packageVersion.setFhirVersion(fhirVersion);
packageVersion.setCurrentVersion(currentVersion); packageVersion.setCurrentVersion(currentVersion);
packageVersion.setPackageSizeBytes(bytes.length); packageVersion.setPackageSizeBytes(bytes.length);
packageVersion.setName(npmPackage.name());
packageVersion = myPackageVersionDao.save(packageVersion); packageVersion = myPackageVersionDao.save(packageVersion);
String dirName = "package"; String dirName = "package";
@ -469,7 +468,7 @@ public class JpaPackageCache extends BasePackageCacheManager implements IHapiPac
NpmPackageMetadataJson.Version version = new NpmPackageMetadataJson.Version(); NpmPackageMetadataJson.Version version = new NpmPackageMetadataJson.Version();
version.setFhirVersion(next.getFhirVersionId()); version.setFhirVersion(next.getFhirVersionId());
version.setDescription(next.getDescription()); version.setDescription(next.getDescription());
version.setName(next.getName()); version.setName(next.getPackageId());
version.setVersion(next.getVersionId()); version.setVersion(next.getVersionId());
version.setBytes(next.getPackageSizeBytes()); version.setBytes(next.getPackageSizeBytes());
retVal.addVersion(version); retVal.addVersion(version);

View File

@ -75,7 +75,52 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
private void init510() { private void init510() {
Builder version = forVersion(VersionEnum.V5_1_0); Builder version = forVersion(VersionEnum.V5_1_0);
// version.addTableByColumns("20200524.1", "") // NPM Packages
version.addIdGenerator("20200610.1", "SEQ_NPM_PACK");
Builder.BuilderAddTableByColumns pkg = version.addTableByColumns("20200610.2", "NPM_PACKAGE", "PID");
pkg.addColumn("PID").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.LONG);
pkg.addColumn("PACKAGE_ID").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, 200);
pkg.addColumn("CUR_VERSION_ID").nullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, 200);
pkg.addColumn("UPDATED_TIME").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.DATE_TIMESTAMP);
pkg.addColumn("PACKAGE_DESC").nullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, 200);
pkg.addIndex("20200610.3", "IDX_PACK_ID").unique(true).withColumns("PACKAGE_ID");
version.addIdGenerator("20200610.4", "SEQ_NPM_PACKVER");
Builder.BuilderAddTableByColumns pkgVer = version.addTableByColumns("20200610.5", "NPM_PACKAGE_VER", "PID");
pkgVer.addColumn("PID").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.LONG);
pkgVer.addColumn("PACKAGE_ID").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, 200);
pkgVer.addColumn("VERSION_ID").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, 200);
pkgVer.addColumn("PACKAGE_PID").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.LONG);
pkgVer.addColumn("BINARY_RES_ID").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.LONG);
pkgVer.addColumn("SAVED_TIME").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.DATE_TIMESTAMP);
pkgVer.addColumn("PKG_DESC").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, 200);
pkgVer.addColumn("DESC_UPPER").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, 200);
pkgVer.addColumn("CURRENT_VERSION").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.BOOLEAN);
pkgVer.addColumn("FHIR_VERSION_ID").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, 10);
pkgVer.addColumn("FHIR_VERSION").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, 10);
pkgVer.addColumn("PACKAGE_SIZE_BYTES").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.LONG);
pkgVer.addColumn("UPDATED_TIME").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.DATE_TIMESTAMP);
pkgVer.addForeignKey("20200610.6", "FK_NPM_PKV_PKG").toColumn("PACKAGE_PID").references("NPM_PACKAGE", "PID");
pkgVer.addForeignKey("20200610.7", "FK_NPM_PKV_RESID").toColumn("BINARY_RES_ID").references("HFJ_RESOURCE", "RES_ID");
pkgVer.addIndex("20200610.8", "IDX_PACKVER").unique(true).withColumns("PACKAGE_ID", "VERSION_ID");
version.addIdGenerator("20200610.9", "SEQ_NPM_PACKVERRES");
Builder.BuilderAddTableByColumns pkgVerRes = version.addTableByColumns("20200610.10", "NPM_PACKAGE_VER_RES", "PID");
pkgVerRes.addColumn("PID").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.LONG);
pkgVerRes.addColumn("PACKVER_PID").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.LONG);
pkgVerRes.addColumn("BINARY_RES_ID").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.LONG);
pkgVerRes.addColumn("FILE_DIR").nullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, 200);
pkgVerRes.addColumn("FILE_NAME").nullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, 200);
pkgVerRes.addColumn("RES_TYPE").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, 40);
pkgVerRes.addColumn("CANONICAL_URL").nullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, 200);
pkgVerRes.addColumn("CANONICAL_VERSION").nullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, 200);
pkgVerRes.addColumn("FHIR_VERSION_ID").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, 10);
pkgVerRes.addColumn("FHIR_VERSION").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, 10);
pkgVerRes.addColumn("RES_SIZE_BYTES").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.LONG);
pkgVerRes.addColumn("UPDATED_TIME").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.DATE_TIMESTAMP);
pkgVerRes.addForeignKey("20200610.11", "FK_NPM_PACKVERRES_PACKVER").toColumn("PACKVER_PID").references("NPM_PACKAGE_VER", "PID");
pkgVerRes.addForeignKey("20200610.12", "FK_NPM_PKVR_RESID").toColumn("BINARY_RES_ID").references("HFJ_RESOURCE", "PID");
pkgVerRes.addIndex("20200610.13", "IDX_PACKVERRES_URL").unique(false).withColumns("CANONICAL_URL");
} }
@ -254,7 +299,7 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
protected void init420() { // 20191015 - 20200217 protected void init420() { // 20191015 - 20200217
Builder version = forVersion(VersionEnum.V4_2_0); Builder version = forVersion(VersionEnum.V4_2_0);
// TermValueSetConceptDesignation // TermValueSetConceptDesignation
version.onTable("TRM_VALUESET_C_DESIGNATION").dropIndex("20200202.1", "IDX_VALUESET_C_DSGNTN_VAL").failureAllowed(); version.onTable("TRM_VALUESET_C_DESIGNATION").dropIndex("20200202.1", "IDX_VALUESET_C_DSGNTN_VAL").failureAllowed();
Builder.BuilderWithTableName searchTable = version.onTable("HFJ_SEARCH"); Builder.BuilderWithTableName searchTable = version.onTable("HFJ_SEARCH");
searchTable.dropIndex("20200203.1", "IDX_SEARCH_LASTRETURNED"); searchTable.dropIndex("20200203.1", "IDX_SEARCH_LASTRETURNED");
@ -454,7 +499,6 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
.renameColumn("20190722.29", "CODE", "CODEVAL", false, true); .renameColumn("20190722.29", "CODE", "CODEVAL", false, true);
// TermValueSet // TermValueSet
version.startSectionWithMessage("Processing table: TRM_VALUESET"); version.startSectionWithMessage("Processing table: TRM_VALUESET");
version.addIdGenerator("20190722.30", "SEQ_VALUESET_PID"); version.addIdGenerator("20190722.30", "SEQ_VALUESET_PID");
@ -757,9 +801,9 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
.nullable() .nullable()
.type(AddColumnTask.ColumnTypeEnum.LONG); .type(AddColumnTask.ColumnTypeEnum.LONG);
spidxString spidxString
.addIndex("20180903.27","IDX_SP_STRING_HASH_EXCT") .addIndex("20180903.27", "IDX_SP_STRING_HASH_EXCT")
.unique(false) .unique(false)
.withColumns( "HASH_EXACT"); .withColumns("HASH_EXACT");
spidxString spidxString
.addTask(new CalculateHashesTask(VersionEnum.V3_5_0, "20180903.28") .addTask(new CalculateHashesTask(VersionEnum.V3_5_0, "20180903.28")
.setColumnName("HASH_NORM_PREFIX") .setColumnName("HASH_NORM_PREFIX")
@ -797,17 +841,17 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
.unique(false) .unique(false)
.withColumns("HASH_IDENTITY"); .withColumns("HASH_IDENTITY");
spidxToken spidxToken
.addIndex("20180903.36","IDX_SP_TOKEN_HASH_S") .addIndex("20180903.36", "IDX_SP_TOKEN_HASH_S")
.unique(false) .unique(false)
.withColumns( "HASH_SYS"); .withColumns("HASH_SYS");
spidxToken spidxToken
.addIndex("20180903.37", "IDX_SP_TOKEN_HASH_SV") .addIndex("20180903.37", "IDX_SP_TOKEN_HASH_SV")
.unique(false) .unique(false)
.withColumns("HASH_SYS_AND_VALUE"); .withColumns("HASH_SYS_AND_VALUE");
spidxToken spidxToken
.addIndex("20180903.38","IDX_SP_TOKEN_HASH_V") .addIndex("20180903.38", "IDX_SP_TOKEN_HASH_V")
.unique(false) .unique(false)
.withColumns( "HASH_VALUE"); .withColumns("HASH_VALUE");
spidxToken spidxToken
.addTask(new CalculateHashesTask(VersionEnum.V3_5_0, "20180903.39") .addTask(new CalculateHashesTask(VersionEnum.V3_5_0, "20180903.39")
.setColumnName("HASH_IDENTITY") .setColumnName("HASH_IDENTITY")
@ -835,9 +879,9 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
.nullable() .nullable()
.type(AddColumnTask.ColumnTypeEnum.LONG); .type(AddColumnTask.ColumnTypeEnum.LONG);
spidxUri spidxUri
.addIndex("20180903.43","IDX_SP_URI_HASH_URI") .addIndex("20180903.43", "IDX_SP_URI_HASH_URI")
.unique(false) .unique(false)
.withColumns( "HASH_URI"); .withColumns("HASH_URI");
spidxUri spidxUri
.addTask(new CalculateHashesTask(VersionEnum.V3_5_0, "20180903.44") .addTask(new CalculateHashesTask(VersionEnum.V3_5_0, "20180903.44")
.setColumnName("HASH_IDENTITY") .setColumnName("HASH_IDENTITY")
@ -893,7 +937,7 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
trmConcept trmConcept
.addIndex("20180903.51", "IDX_CONCEPT_UPDATED") .addIndex("20180903.51", "IDX_CONCEPT_UPDATED")
.unique(false) .unique(false)
.withColumns( "CONCEPT_UPDATED"); .withColumns("CONCEPT_UPDATED");
trmConcept trmConcept
.modifyColumn("20180903.52", "CODE") .modifyColumn("20180903.52", "CODE")
.nonNullable() .nonNullable()

View File

@ -49,7 +49,7 @@ import java.util.List;
@Entity() @Entity()
@Table(name = "NPM_PACKAGE_VER", uniqueConstraints = { @Table(name = "NPM_PACKAGE_VER", uniqueConstraints = {
}, indexes = { }, indexes = {
@Index(name = "IDX_PACKVER", columnList = "PACKAGE_ID,VERSION_ID") @Index(name = "IDX_PACKVER", columnList = "PACKAGE_ID,VERSION_ID", unique = true)
}) })
public class NpmPackageVersionEntity { public class NpmPackageVersionEntity {
@ -74,9 +74,9 @@ public class NpmPackageVersionEntity {
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
@Column(name = "SAVED_TIME", nullable = false) @Column(name = "SAVED_TIME", nullable = false)
private Date mySavedTime; private Date mySavedTime;
@Column(name = "PKG_DESC", nullable = false, length = 500) @Column(name = "PKG_DESC", nullable = false, length = 200)
private String myDescription; private String myDescription;
@Column(name = "DESC_UPPER", nullable = false, length = 500) @Column(name = "DESC_UPPER", nullable = false, length = 200)
private String myDescriptionUpper; private String myDescriptionUpper;
@Column(name = "CURRENT_VERSION", nullable = false) @Column(name = "CURRENT_VERSION", nullable = false)
private boolean myCurrentVersion; private boolean myCurrentVersion;
@ -91,8 +91,6 @@ public class NpmPackageVersionEntity {
@Version @Version
@Column(name = "UPDATED_TIME", nullable = false) @Column(name = "UPDATED_TIME", nullable = false)
private Date myUpdatedTime; private Date myUpdatedTime;
@Column(name = "PACKAGE_NAME", nullable = true, length = 200)
private String myName;
@OneToMany(mappedBy = "myPackageVersion") @OneToMany(mappedBy = "myPackageVersion")
private List<NpmPackageVersionResourceEntity> myResources; private List<NpmPackageVersionResourceEntity> myResources;
@ -188,14 +186,6 @@ public class NpmPackageVersionEntity {
.toString(); .toString();
} }
public String getName() {
return myName;
}
public void setName(String theName) {
myName = theName;
}
public List<NpmPackageVersionResourceEntity> getResources() { public List<NpmPackageVersionResourceEntity> getResources() {
return myResources; return myResources;
} }

View File

@ -48,15 +48,13 @@ import java.util.Date;
}) })
public class NpmPackageVersionResourceEntity { public class NpmPackageVersionResourceEntity {
public static final int VERSION_ID_LENGTH = 200;
@Id @Id
@SequenceGenerator(name = "SEQ_NPM_PACKVERRES", sequenceName = "SEQ_NPM_PACKVERRES") @SequenceGenerator(name = "SEQ_NPM_PACKVERRES", sequenceName = "SEQ_NPM_PACKVERRES")
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_NPM_PACKVERRES") @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_NPM_PACKVERRES")
@Column(name = "SP_ID") @Column(name = "PID")
private Long myId; private Long myId;
@ManyToOne @ManyToOne
@JoinColumn(name = "PACKVER_PID", referencedColumnName = "PID", foreignKey = @ForeignKey(name = "FK_NPM_PACKVERRES_PACKVER")) @JoinColumn(name = "PACKVER_PID", referencedColumnName = "PID", foreignKey = @ForeignKey(name = "FK_NPM_PACKVERRES_PACKVER"), nullable = false)
private NpmPackageVersionEntity myPackageVersion; private NpmPackageVersionEntity myPackageVersion;
@OneToOne @OneToOne
@JoinColumn(name = "BINARY_RES_ID", referencedColumnName = "RES_ID", nullable = false, foreignKey = @ForeignKey(name = "FK_NPM_PKVR_RESID")) @JoinColumn(name = "BINARY_RES_ID", referencedColumnName = "RES_ID", nullable = false, foreignKey = @ForeignKey(name = "FK_NPM_PKVR_RESID"))
@ -65,7 +63,7 @@ public class NpmPackageVersionResourceEntity {
private String myDirectory; private String myDirectory;
@Column(name = "FILE_NAME", length = 200) @Column(name = "FILE_NAME", length = 200)
private String myFilename; private String myFilename;
@Column(name = "RES_TYPE", length = ResourceTable.RESTYPE_LEN) @Column(name = "RES_TYPE", length = ResourceTable.RESTYPE_LEN, nullable = false)
private String myResourceType; private String myResourceType;
@Column(name = "CANONICAL_URL", length = 200) @Column(name = "CANONICAL_URL", length = 200)
private String myCanonicalUrl; private String myCanonicalUrl;