public VariantMetadata toVariantMetadata(Collection<StudyConfiguration> studyConfigurations, ProjectMetadata projectMetadata, Map<Integer, List<Integer>> returnedSamples, Map<Integer, List<Integer>> returnedFiles) { List<VariantStudyMetadata> studies = new ArrayList<>(); String specie = projectMetadata.getSpecies(); String assembly = projectMetadata.getAssembly(); for (StudyConfiguration studyConfiguration : studyConfigurations) { VariantStudyMetadata studyMetadata = toVariantStudyMetadata(studyConfiguration, returnedSamples == null ? null : returnedSamples.get(studyConfiguration.getStudyId()), returnedFiles == null ? null : returnedFiles.get(studyConfiguration.getStudyId())); studies.add(studyMetadata); } Species species = Species.newBuilder() .setId(specie) .setAssembly(assembly) .build(); return VariantMetadata.newBuilder() // .setDate(Date.from(Instant.now()).toString()) .setCreationDate(TimeUtils.getTime()) .setStudies(studies) .setVersion(GitRepositoryState.get().getDescribeShort()) .setSpecies(species) .build(); }
/** Creates a Builder by copying an existing VariantMetadata instance */ private Builder(org.opencb.biodata.models.variant.metadata.VariantMetadata other) { super(org.opencb.biodata.models.variant.metadata.VariantMetadata.SCHEMA$); if (isValidValue(fields()[0], other.version)) { this.version = data().deepCopy(fields()[0].schema(), other.version); fieldSetFlags()[0] = true; } if (isValidValue(fields()[1], other.species)) { this.species = data().deepCopy(fields()[1].schema(), other.species); fieldSetFlags()[1] = true; } if (isValidValue(fields()[2], other.creationDate)) { this.creationDate = data().deepCopy(fields()[2].schema(), other.creationDate); fieldSetFlags()[2] = true; } if (isValidValue(fields()[3], other.description)) { this.description = data().deepCopy(fields()[3].schema(), other.description); fieldSetFlags()[3] = true; } if (isValidValue(fields()[4], other.studies)) { this.studies = data().deepCopy(fields()[4].schema(), other.studies); fieldSetFlags()[4] = true; } }
@Override public VariantMetadata build() { try { VariantMetadata record = new VariantMetadata(); record.version = fieldSetFlags()[0] ? this.version : (java.lang.String) defaultValue(fields()[0]); record.species = fieldSetFlags()[1] ? this.species : (org.opencb.biodata.models.metadata.Species) defaultValue(fields()[1]); record.creationDate = fieldSetFlags()[2] ? this.creationDate : (java.lang.String) defaultValue(fields()[2]); record.description = fieldSetFlags()[3] ? this.description : (java.lang.String) defaultValue(fields()[3]); record.studies = fieldSetFlags()[4] ? this.studies : (java.util.List<org.opencb.biodata.models.variant.metadata.VariantStudyMetadata>) defaultValue(fields()[4]); return record; } catch (Exception e) { throw new org.apache.avro.AvroRuntimeException(e); } } }
/** Creates a Builder by copying an existing Builder */ private Builder(org.opencb.biodata.models.variant.metadata.VariantMetadata.Builder other) { super(other); if (isValidValue(fields()[0], other.version)) { this.version = data().deepCopy(fields()[0].schema(), other.version); fieldSetFlags()[0] = true; } if (isValidValue(fields()[1], other.species)) { this.species = data().deepCopy(fields()[1].schema(), other.species); fieldSetFlags()[1] = true; } if (isValidValue(fields()[2], other.creationDate)) { this.creationDate = data().deepCopy(fields()[2].schema(), other.creationDate); fieldSetFlags()[2] = true; } if (isValidValue(fields()[3], other.description)) { this.description = data().deepCopy(fields()[3].schema(), other.description); fieldSetFlags()[3] = true; } if (isValidValue(fields()[4], other.studies)) { this.studies = data().deepCopy(fields()[4].schema(), other.studies); fieldSetFlags()[4] = true; } }
/** Checks whether the 'species' field has been set */ public boolean hasSpecies() { return fieldSetFlags()[1]; }
/** Checks whether the 'version' field has been set */ public boolean hasVersion() { return fieldSetFlags()[0]; }
/** Checks whether the 'creationDate' field has been set */ public boolean hasCreationDate() { return fieldSetFlags()[2]; }
/** Creates a new VariantMetadata RecordBuilder by copying an existing VariantMetadata instance */ public static org.opencb.biodata.models.variant.metadata.VariantMetadata.Builder newBuilder(org.opencb.biodata.models.variant.metadata.VariantMetadata other) { return new org.opencb.biodata.models.variant.metadata.VariantMetadata.Builder(other); }
/** Creates a new VariantMetadata RecordBuilder */ public static org.opencb.biodata.models.variant.metadata.VariantMetadata.Builder newBuilder() { return new org.opencb.biodata.models.variant.metadata.VariantMetadata.Builder(); }
/** Checks whether the 'description' field has been set */ public boolean hasDescription() { return fieldSetFlags()[3]; }
/** Clears the value of the 'studies' field */ public org.opencb.biodata.models.variant.metadata.VariantMetadata.Builder clearStudies() { studies = null; fieldSetFlags()[4] = false; return this; }
/** Clears the value of the 'creationDate' field */ public org.opencb.biodata.models.variant.metadata.VariantMetadata.Builder clearCreationDate() { creationDate = null; fieldSetFlags()[2] = false; return this; }
/** Clears the value of the 'version' field */ public org.opencb.biodata.models.variant.metadata.VariantMetadata.Builder clearVersion() { version = null; fieldSetFlags()[0] = false; return this; }
/** Sets the value of the 'version' field */ public org.opencb.biodata.models.variant.metadata.VariantMetadata.Builder setVersion(java.lang.String value) { validate(fields()[0], value); this.version = value; fieldSetFlags()[0] = true; return this; }
/** Sets the value of the 'creationDate' field */ public org.opencb.biodata.models.variant.metadata.VariantMetadata.Builder setCreationDate(java.lang.String value) { validate(fields()[2], value); this.creationDate = value; fieldSetFlags()[2] = true; return this; }
/** Sets the value of the 'studies' field */ public org.opencb.biodata.models.variant.metadata.VariantMetadata.Builder setStudies(java.util.List<org.opencb.biodata.models.variant.metadata.VariantStudyMetadata> value) { validate(fields()[4], value); this.studies = value; fieldSetFlags()[4] = true; return this; }
/** Sets the value of the 'description' field */ public org.opencb.biodata.models.variant.metadata.VariantMetadata.Builder setDescription(java.lang.String value) { validate(fields()[3], value); this.description = value; fieldSetFlags()[3] = true; return this; }
/** Sets the value of the 'species' field */ public org.opencb.biodata.models.variant.metadata.VariantMetadata.Builder setSpecies(org.opencb.biodata.models.metadata.Species value) { validate(fields()[1], value); this.species = value; fieldSetFlags()[1] = true; return this; }
/** Checks whether the 'studies' field has been set */ public boolean hasStudies() { return fieldSetFlags()[4]; }
/** Creates a new VariantMetadata RecordBuilder by copying an existing Builder */ public static org.opencb.biodata.models.variant.metadata.VariantMetadata.Builder newBuilder(org.opencb.biodata.models.variant.metadata.VariantMetadata.Builder other) { return new org.opencb.biodata.models.variant.metadata.VariantMetadata.Builder(other); }