Mark packages as unsuitable for publication
This commit is contained in:
parent
c3b21733fd
commit
e1f53eec47
|
@ -104,17 +104,17 @@ public class NPMPackageGenerator {
|
||||||
private NpmPackageIndexBuilder indexer;
|
private NpmPackageIndexBuilder indexer;
|
||||||
|
|
||||||
|
|
||||||
public NPMPackageGenerator(String destFile, String canonical, String url, PackageType kind, ImplementationGuide ig, Date date) throws FHIRException, IOException {
|
public NPMPackageGenerator(String destFile, String canonical, String url, PackageType kind, ImplementationGuide ig, Date date, boolean notForPublication) throws FHIRException, IOException {
|
||||||
super();
|
super();
|
||||||
this.destFile = destFile;
|
this.destFile = destFile;
|
||||||
start();
|
start();
|
||||||
List<String> fhirVersion = new ArrayList<>();
|
List<String> fhirVersion = new ArrayList<>();
|
||||||
for (Enumeration<FHIRVersion> v : ig.getFhirVersion())
|
for (Enumeration<FHIRVersion> v : ig.getFhirVersion())
|
||||||
fhirVersion.add(v.asStringValue());
|
fhirVersion.add(v.asStringValue());
|
||||||
buildPackageJson(canonical, kind, url, date, ig, fhirVersion);
|
buildPackageJson(canonical, kind, url, date, ig, fhirVersion, notForPublication);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NPMPackageGenerator subset(NPMPackageGenerator master, String destFile, String id, String name, Date date) throws FHIRException, IOException {
|
public static NPMPackageGenerator subset(NPMPackageGenerator master, String destFile, String id, String name, Date date, boolean notForPublication) throws FHIRException, IOException {
|
||||||
JsonObject p = master.packageJ.deepCopy();
|
JsonObject p = master.packageJ.deepCopy();
|
||||||
p.remove("name");
|
p.remove("name");
|
||||||
p.addProperty("name", id);
|
p.addProperty("name", id);
|
||||||
|
@ -122,24 +122,30 @@ public class NPMPackageGenerator {
|
||||||
p.addProperty("type", PackageType.SUBSET.getCode());
|
p.addProperty("type", PackageType.SUBSET.getCode());
|
||||||
p.remove("title");
|
p.remove("title");
|
||||||
p.addProperty("title", name);
|
p.addProperty("title", name);
|
||||||
|
if (notForPublication) {
|
||||||
return new NPMPackageGenerator(destFile, p, date);
|
p.addProperty("notForPublication", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NPMPackageGenerator(String destFile, String canonical, String url, PackageType kind, ImplementationGuide ig, Date date, List<String> fhirVersion) throws FHIRException, IOException {
|
return new NPMPackageGenerator(destFile, p, date, notForPublication);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NPMPackageGenerator(String destFile, String canonical, String url, PackageType kind, ImplementationGuide ig, Date date, List<String> fhirVersion, boolean notForPublication) throws FHIRException, IOException {
|
||||||
super();
|
super();
|
||||||
this.destFile = destFile;
|
this.destFile = destFile;
|
||||||
start();
|
start();
|
||||||
buildPackageJson(canonical, kind, url, date, ig, fhirVersion);
|
buildPackageJson(canonical, kind, url, date, ig, fhirVersion, notForPublication);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NPMPackageGenerator(String destFile, JsonObject npm, Date date) throws FHIRException, IOException {
|
public NPMPackageGenerator(String destFile, JsonObject npm, Date date, boolean notForPublication) throws FHIRException, IOException {
|
||||||
super();
|
super();
|
||||||
String dt = new SimpleDateFormat("yyyyMMddHHmmss").format(date);
|
String dt = new SimpleDateFormat("yyyyMMddHHmmss").format(date);
|
||||||
packageJ = npm;
|
packageJ = npm;
|
||||||
packageManifest = new JsonObject();
|
packageManifest = new JsonObject();
|
||||||
packageManifest.addProperty("version", npm.get("version").getAsString());
|
packageManifest.addProperty("version", npm.get("version").getAsString());
|
||||||
packageManifest.addProperty("date", dt);
|
packageManifest.addProperty("date", dt);
|
||||||
|
if (notForPublication) {
|
||||||
|
packageManifest.addProperty("notForPublication", true);
|
||||||
|
}
|
||||||
npm.addProperty("date", dt);
|
npm.addProperty("date", dt);
|
||||||
packageManifest.addProperty("name", npm.get("name").getAsString());
|
packageManifest.addProperty("name", npm.get("name").getAsString());
|
||||||
this.destFile = destFile;
|
this.destFile = destFile;
|
||||||
|
@ -152,19 +158,23 @@ public class NPMPackageGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildPackageJson(String canonical, PackageType kind, String web, Date date, ImplementationGuide ig, List<String> fhirVersion) throws FHIRException, IOException {
|
private void buildPackageJson(String canonical, PackageType kind, String web, Date date, ImplementationGuide ig, List<String> fhirVersion, boolean notForPublication) throws FHIRException, IOException {
|
||||||
String dtHuman = new SimpleDateFormat("EEE, MMM d, yyyy HH:mmZ", new Locale("en", "US")).format(date);
|
String dtHuman = new SimpleDateFormat("EEE, MMM d, yyyy HH:mmZ", new Locale("en", "US")).format(date);
|
||||||
String dt = new SimpleDateFormat("yyyyMMddHHmmss").format(date);
|
String dt = new SimpleDateFormat("yyyyMMddHHmmss").format(date);
|
||||||
|
|
||||||
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
|
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
|
||||||
if (!ig.hasPackageId())
|
if (!ig.hasPackageId()) {
|
||||||
b.append("packageId");
|
b.append("packageId");
|
||||||
if (!ig.hasVersion())
|
}
|
||||||
|
if (!ig.hasVersion()) {
|
||||||
b.append("version");
|
b.append("version");
|
||||||
if (!ig.hasFhirVersion())
|
}
|
||||||
|
if (!ig.hasFhirVersion()) {
|
||||||
b.append("fhirVersion");
|
b.append("fhirVersion");
|
||||||
if (!ig.hasLicense())
|
}
|
||||||
|
if (!ig.hasLicense()) {
|
||||||
b.append("license");
|
b.append("license");
|
||||||
|
}
|
||||||
for (ImplementationGuideDependsOnComponent d : ig.getDependsOn()) {
|
for (ImplementationGuideDependsOnComponent d : ig.getDependsOn()) {
|
||||||
if (!d.hasVersion()) {
|
if (!d.hasVersion()) {
|
||||||
b.append("dependsOn.version("+d.getUri()+")");
|
b.append("dependsOn.version("+d.getUri()+")");
|
||||||
|
@ -177,14 +187,20 @@ public class NPMPackageGenerator {
|
||||||
npm.addProperty("tools-version", ToolsVersion.TOOLS_VERSION);
|
npm.addProperty("tools-version", ToolsVersion.TOOLS_VERSION);
|
||||||
npm.addProperty("type", kind.getCode());
|
npm.addProperty("type", kind.getCode());
|
||||||
npm.addProperty("date", dt);
|
npm.addProperty("date", dt);
|
||||||
if (ig.hasLicense())
|
if (ig.hasLicense()) {
|
||||||
npm.addProperty("license", ig.getLicense().toCode());
|
npm.addProperty("license", ig.getLicense().toCode());
|
||||||
|
}
|
||||||
npm.addProperty("canonical", canonical);
|
npm.addProperty("canonical", canonical);
|
||||||
|
if (notForPublication) {
|
||||||
|
npm.addProperty("notForPublication", true);
|
||||||
|
}
|
||||||
npm.addProperty("url", web);
|
npm.addProperty("url", web);
|
||||||
if (ig.hasTitle())
|
if (ig.hasTitle()) {
|
||||||
npm.addProperty("title", ig.getTitle());
|
npm.addProperty("title", ig.getTitle());
|
||||||
if (ig.hasDescription())
|
}
|
||||||
|
if (ig.hasDescription()) {
|
||||||
npm.addProperty("description", ig.getDescription()+ " (built "+dtHuman+timezone()+")");
|
npm.addProperty("description", ig.getDescription()+ " (built "+dtHuman+timezone()+")");
|
||||||
|
}
|
||||||
JsonArray vl = new JsonArray();
|
JsonArray vl = new JsonArray();
|
||||||
|
|
||||||
npm.add("fhirVersions", vl);
|
npm.add("fhirVersions", vl);
|
||||||
|
@ -205,8 +221,9 @@ public class NPMPackageGenerator {
|
||||||
dep.addProperty(d.getPackageId(), d.getVersion());
|
dep.addProperty(d.getPackageId(), d.getVersion());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ig.hasPublisher())
|
if (ig.hasPublisher()) {
|
||||||
npm.addProperty("author", ig.getPublisher());
|
npm.addProperty("author", ig.getPublisher());
|
||||||
|
}
|
||||||
JsonArray m = new JsonArray();
|
JsonArray m = new JsonArray();
|
||||||
for (ContactDetail t : ig.getContact()) {
|
for (ContactDetail t : ig.getContact()) {
|
||||||
String email = email(t.getTelecom());
|
String email = email(t.getTelecom());
|
||||||
|
|
|
@ -1092,5 +1092,9 @@ public class NpmPackage {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isNotForPublication() {
|
||||||
|
return JSONUtil.bool(npm, "notForPublication");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue