
001package ca.uhn.fhir.jpa.packages; 002 003/* 004 * #%L 005 * HAPI FHIR JPA Server 006 * %% 007 * Copyright (C) 2014 - 2022 Smile CDR, Inc. 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 022 023import ca.uhn.fhir.jpa.util.JsonDateDeserializer; 024import ca.uhn.fhir.jpa.util.JsonDateSerializer; 025import com.fasterxml.jackson.annotation.JsonAutoDetect; 026import com.fasterxml.jackson.annotation.JsonInclude; 027import com.fasterxml.jackson.annotation.JsonProperty; 028import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 029import com.fasterxml.jackson.databind.annotation.JsonSerialize; 030import io.swagger.v3.oas.annotations.media.Schema; 031 032import javax.annotation.Nonnull; 033import java.util.Date; 034import java.util.LinkedHashMap; 035import java.util.Map; 036 037@Schema(description = "Represents an NPM package metadata response") 038@JsonInclude(JsonInclude.Include.NON_NULL) 039@JsonAutoDetect(creatorVisibility = JsonAutoDetect.Visibility.NONE, fieldVisibility = JsonAutoDetect.Visibility.NONE, getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE) 040public class NpmPackageMetadataJson { 041 042 @JsonProperty("dist-tags") 043 private DistTags myDistTags; 044 @JsonProperty("modified") 045 @JsonSerialize(using = JsonDateSerializer.class) 046 @JsonDeserialize(using = JsonDateDeserializer.class) 047 private Date myModified; 048 @JsonProperty("name") 049 private String myName; 050 @JsonProperty("versions") 051 private Map<String, Version> myVersionIdToVersion; 052 053 public void addVersion(Version theVersion) { 054 getVersions().put(theVersion.getVersion(), theVersion); 055 } 056 057 @Nonnull 058 public Map<String, Version> getVersions() { 059 if (myVersionIdToVersion == null) { 060 myVersionIdToVersion = new LinkedHashMap<>(); 061 } 062 return myVersionIdToVersion; 063 } 064 065 public DistTags getDistTags() { 066 return myDistTags; 067 } 068 069 public void setDistTags(DistTags theDistTags) { 070 myDistTags = theDistTags; 071 } 072 073 public void setModified(Date theModified) { 074 myModified = theModified; 075 } 076 077 public void setName(String theName) { 078 myName = theName; 079 } 080 081 082 public static class DistTags { 083 084 @JsonProperty("latest") 085 private String myLatest; 086 087 public String getLatest() { 088 return myLatest; 089 } 090 091 public DistTags setLatest(String theLatest) { 092 myLatest = theLatest; 093 return this; 094 } 095 } 096 097 098 @JsonInclude(JsonInclude.Include.NON_NULL) 099 @JsonAutoDetect(creatorVisibility = JsonAutoDetect.Visibility.NONE, fieldVisibility = JsonAutoDetect.Visibility.NONE, getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE) 100 public static class Version { 101 102 @JsonProperty("name") 103 private String myName; 104 @JsonProperty("version") 105 private String myVersion; 106 @JsonProperty("description") 107 private String myDescription; 108 @JsonProperty("fhirVersion") 109 private String myFhirVersion; 110 @Schema(description = "The size of this package in bytes", example = "1000") 111 @JsonProperty("_bytes") 112 private long myBytes; 113 114 public String getName() { 115 return myName; 116 } 117 118 public void setName(String theName) { 119 myName = theName; 120 } 121 122 public String getDescription() { 123 return myDescription; 124 } 125 126 public void setDescription(String theDescription) { 127 myDescription = theDescription; 128 } 129 130 public String getFhirVersion() { 131 return myFhirVersion; 132 } 133 134 public void setFhirVersion(String theFhirVersion) { 135 myFhirVersion = theFhirVersion; 136 } 137 138 public String getVersion() { 139 return myVersion; 140 } 141 142 public void setVersion(String theVersion) { 143 myVersion = theVersion; 144 } 145 146 public long getBytes() { 147 return myBytes; 148 } 149 150 public void setBytes(long theBytes) { 151 myBytes = theBytes; 152 } 153 } 154}