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

View File

@ -75,7 +75,52 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
private void init510() {
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");
}
@ -454,7 +499,6 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
.renameColumn("20190722.29", "CODE", "CODEVAL", false, true);
// TermValueSet
version.startSectionWithMessage("Processing table: TRM_VALUESET");
version.addIdGenerator("20190722.30", "SEQ_VALUESET_PID");

View File

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

View File

@ -48,15 +48,13 @@ import java.util.Date;
})
public class NpmPackageVersionResourceEntity {
public static final int VERSION_ID_LENGTH = 200;
@Id
@SequenceGenerator(name = "SEQ_NPM_PACKVERRES", sequenceName = "SEQ_NPM_PACKVERRES")
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_NPM_PACKVERRES")
@Column(name = "SP_ID")
@Column(name = "PID")
private Long myId;
@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;
@OneToOne
@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;
@Column(name = "FILE_NAME", length = 200)
private String myFilename;
@Column(name = "RES_TYPE", length = ResourceTable.RESTYPE_LEN)
@Column(name = "RES_TYPE", length = ResourceTable.RESTYPE_LEN, nullable = false)
private String myResourceType;
@Column(name = "CANONICAL_URL", length = 200)
private String myCanonicalUrl;