@Test public void checkCopyThreddsMetadataBuilderVariables() { ThreddsBuilderFactory fac = new ThreddsBuilderFactoryImpl(); ThreddsMetadataBuilder srcTmBldr = fac.newThreddsMetadataBuilder(); ThreddsMetadataBuilder.VariableGroupBuilder srcVarGrpBldr = srcTmBldr.addVariableGroupBuilder(); String vocabAuthId = "vocabAuthId"; srcVarGrpBldr.setVocabularyAuthorityId( vocabAuthId ); String name = "name"; srcVarGrpBldr.addVariableBuilder( name, "descrip", "units", "vocabId", "vocabName" ); ThreddsMetadataBuilder recipientTmBldr = fac.newThreddsMetadataBuilder(); assertNotNull( recipientTmBldr); assertTrue( recipientTmBldr.getVariableGroupBuilders().isEmpty()); ThreddsMetadataBuilderUtils.copyThreddsMetadataBuilder( srcTmBldr, recipientTmBldr ); List<ThreddsMetadataBuilder.VariableGroupBuilder> recipientVarGrpBldrs = recipientTmBldr.getVariableGroupBuilders(); assertFalse( recipientVarGrpBldrs.isEmpty() ); assertEquals( 1, recipientVarGrpBldrs.size()); ThreddsMetadataBuilder.VariableGroupBuilder recipientVarGrpBldr = recipientVarGrpBldrs.get( 0); assertEquals( vocabAuthId, recipientVarGrpBldr.getVocabularyAuthorityId()); List<ThreddsMetadataBuilder.VariableBuilder> variableBuilderList = recipientVarGrpBldr.getVariableBuilders(); assertEquals( 1, variableBuilderList.size()); ThreddsMetadataBuilder.VariableBuilder varBldr = variableBuilderList.get( 0); assertEquals( name, varBldr.getName()); }
public static ThreddsMetadataBuilder copyThreddsMetadataBuilder( ThreddsMetadataBuilder source, ThreddsMetadataBuilder recipient ) { if ( source == null ) throw new IllegalArgumentException( "Source builder may not be null." ); if ( recipient == null ) throw new IllegalArgumentException( "Recipient builder may not be null."); if ( source.getCollectionType() != null ) recipient.setCollectionType( source.getCollectionType() ); if ( source.getDataFormat() != null ) recipient.setDataFormat( source.getDataFormat() ); recipient.setDataSizeInBytes( source.getDataSizeInBytes()); if ( source.getDataType() != null ) recipient.setDataType( source.getDataType() ); if ( source.getAvailableDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getAvailableDatePointBuilder(); recipient.setAvailableDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getCreatedDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getCreatedDatePointBuilder(); recipient.setCreatedDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getIssuedDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getIssuedDatePointBuilder(); recipient.setIssuedDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getMetadataCreatedDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getMetadataCreatedDatePointBuilder(); recipient.setMetadataCreatedDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getMetadataModifiedDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getMetadataModifiedDatePointBuilder(); recipient.setMetadataModifiedDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getModifiedDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getModifiedDatePointBuilder(); recipient.setModifiedDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getValidDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getValidDatePointBuilder(); recipient.setValidDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } ThreddsMetadataBuilder.GeospatialCoverageBuilder geoCovBuilder = source.getGeospatialCoverageBuilder(); if ( geoCovBuilder != null ) if ( geoCovBuilder.getCRS() != null ) recipient.setNewGeospatialCoverageBuilder( geoCovBuilder.getCRS() ); if ( source.getTemporalCoverageBuilder() != null ) { ThreddsMetadataBuilder.DateRangeBuilder drb = source.getTemporalCoverageBuilder(); recipient.setTemporalCoverageBuilder( drb.getStartDate(), drb.getStartDateFormat(), drb.getEndDate(), drb.getEndDateFormat(), drb.getDuration(), drb.getResolution() ); } addCopiesOfContributorBuilders( source, recipient ); addCopiesOfCreatorBuilders( source, recipient ); addCopiesOfDocumentationBuilders( source, recipient ); addCopiesOfKeyphraseBuilders( source, recipient ); addCopiesOfProjectNameBuilders( source, recipient ); addCopiesOfPublisherBuilders( source, recipient ); addCopiesOfVariableGroupBuilders( source, recipient ); return recipient; }
ThreddsMetadataBuilderUtils { public static ThreddsMetadataBuilder copyThreddsMetadataBuilder( ThreddsMetadataBuilder source, ThreddsMetadataBuilder recipient ) { if ( source == null ) throw new IllegalArgumentException( "Source builder may not be null." ); if ( recipient == null ) throw new IllegalArgumentException( "Recipient builder may not be null."); if ( source.getCollectionType() != null ) recipient.setCollectionType( source.getCollectionType() ); if ( source.getDataFormat() != null ) recipient.setDataFormat( source.getDataFormat() ); recipient.setDataSizeInBytes( source.getDataSizeInBytes()); if ( source.getDataType() != null ) recipient.setDataType( source.getDataType() ); if ( source.getAvailableDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getAvailableDatePointBuilder(); recipient.setAvailableDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getCreatedDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getCreatedDatePointBuilder(); recipient.setCreatedDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getIssuedDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getIssuedDatePointBuilder(); recipient.setIssuedDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getMetadataCreatedDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getMetadataCreatedDatePointBuilder(); recipient.setMetadataCreatedDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getMetadataModifiedDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getMetadataModifiedDatePointBuilder(); recipient.setMetadataModifiedDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getModifiedDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getModifiedDatePointBuilder(); recipient.setModifiedDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getValidDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getValidDatePointBuilder(); recipient.setValidDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } ThreddsMetadataBuilder.GeospatialCoverageBuilder geoCovBuilder = source.getGeospatialCoverageBuilder(); if ( geoCovBuilder != null ) if ( geoCovBuilder.getCRS() != null ) recipient.setNewGeospatialCoverageBuilder( geoCovBuilder.getCRS() ); if ( source.getTemporalCoverageBuilder() != null ) { ThreddsMetadataBuilder.DateRangeBuilder drb = source.getTemporalCoverageBuilder(); recipient.setTemporalCoverageBuilder( drb.getStartDate(), drb.getStartDateFormat(), drb.getEndDate(), drb.getEndDateFormat(), drb.getDuration(), drb.getResolution() ); } addCopiesOfContributorBuilders( source, recipient ); addCopiesOfCreatorBuilders( source, recipient ); addCopiesOfDocumentationBuilders( source, recipient ); addCopiesOfKeyphraseBuilders( source, recipient ); addCopiesOfProjectNameBuilders( source, recipient ); addCopiesOfPublisherBuilders( source, recipient ); addCopiesOfVariableGroupBuilders( source, recipient ); return recipient; } }
ThreddsMetadataBuilderUtils { public static ThreddsMetadataBuilder copyThreddsMetadataBuilder( ThreddsMetadataBuilder source, ThreddsMetadataBuilder recipient ) { if ( source == null ) throw new IllegalArgumentException( "Source builder may not be null." ); if ( recipient == null ) throw new IllegalArgumentException( "Recipient builder may not be null."); if ( source.getCollectionType() != null ) recipient.setCollectionType( source.getCollectionType() ); if ( source.getDataFormat() != null ) recipient.setDataFormat( source.getDataFormat() ); recipient.setDataSizeInBytes( source.getDataSizeInBytes()); if ( source.getDataType() != null ) recipient.setDataType( source.getDataType() ); if ( source.getAvailableDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getAvailableDatePointBuilder(); recipient.setAvailableDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getCreatedDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getCreatedDatePointBuilder(); recipient.setCreatedDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getIssuedDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getIssuedDatePointBuilder(); recipient.setIssuedDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getMetadataCreatedDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getMetadataCreatedDatePointBuilder(); recipient.setMetadataCreatedDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getMetadataModifiedDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getMetadataModifiedDatePointBuilder(); recipient.setMetadataModifiedDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getModifiedDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getModifiedDatePointBuilder(); recipient.setModifiedDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getValidDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getValidDatePointBuilder(); recipient.setValidDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } ThreddsMetadataBuilder.GeospatialCoverageBuilder geoCovBuilder = source.getGeospatialCoverageBuilder(); if ( geoCovBuilder != null ) if ( geoCovBuilder.getCRS() != null ) recipient.setNewGeospatialCoverageBuilder( geoCovBuilder.getCRS() ); if ( source.getTemporalCoverageBuilder() != null ) { ThreddsMetadataBuilder.DateRangeBuilder drb = source.getTemporalCoverageBuilder(); recipient.setTemporalCoverageBuilder( drb.getStartDate(), drb.getStartDateFormat(), drb.getEndDate(), drb.getEndDateFormat(), drb.getDuration(), drb.getResolution() ); } addCopiesOfContributorBuilders( source, recipient ); addCopiesOfCreatorBuilders( source, recipient ); addCopiesOfDocumentationBuilders( source, recipient ); addCopiesOfKeyphraseBuilders( source, recipient ); addCopiesOfProjectNameBuilders( source, recipient ); addCopiesOfPublisherBuilders( source, recipient ); addCopiesOfVariableGroupBuilders( source, recipient ); return recipient; } private  ThreddsMetadataBuilderUtils(); }
ThreddsMetadataBuilderUtils { public static ThreddsMetadataBuilder copyThreddsMetadataBuilder( ThreddsMetadataBuilder source, ThreddsMetadataBuilder recipient ) { if ( source == null ) throw new IllegalArgumentException( "Source builder may not be null." ); if ( recipient == null ) throw new IllegalArgumentException( "Recipient builder may not be null."); if ( source.getCollectionType() != null ) recipient.setCollectionType( source.getCollectionType() ); if ( source.getDataFormat() != null ) recipient.setDataFormat( source.getDataFormat() ); recipient.setDataSizeInBytes( source.getDataSizeInBytes()); if ( source.getDataType() != null ) recipient.setDataType( source.getDataType() ); if ( source.getAvailableDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getAvailableDatePointBuilder(); recipient.setAvailableDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getCreatedDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getCreatedDatePointBuilder(); recipient.setCreatedDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getIssuedDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getIssuedDatePointBuilder(); recipient.setIssuedDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getMetadataCreatedDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getMetadataCreatedDatePointBuilder(); recipient.setMetadataCreatedDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getMetadataModifiedDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getMetadataModifiedDatePointBuilder(); recipient.setMetadataModifiedDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getModifiedDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getModifiedDatePointBuilder(); recipient.setModifiedDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getValidDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getValidDatePointBuilder(); recipient.setValidDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } ThreddsMetadataBuilder.GeospatialCoverageBuilder geoCovBuilder = source.getGeospatialCoverageBuilder(); if ( geoCovBuilder != null ) if ( geoCovBuilder.getCRS() != null ) recipient.setNewGeospatialCoverageBuilder( geoCovBuilder.getCRS() ); if ( source.getTemporalCoverageBuilder() != null ) { ThreddsMetadataBuilder.DateRangeBuilder drb = source.getTemporalCoverageBuilder(); recipient.setTemporalCoverageBuilder( drb.getStartDate(), drb.getStartDateFormat(), drb.getEndDate(), drb.getEndDateFormat(), drb.getDuration(), drb.getResolution() ); } addCopiesOfContributorBuilders( source, recipient ); addCopiesOfCreatorBuilders( source, recipient ); addCopiesOfDocumentationBuilders( source, recipient ); addCopiesOfKeyphraseBuilders( source, recipient ); addCopiesOfProjectNameBuilders( source, recipient ); addCopiesOfPublisherBuilders( source, recipient ); addCopiesOfVariableGroupBuilders( source, recipient ); return recipient; } private  ThreddsMetadataBuilderUtils(); static ThreddsMetadataBuilder copyIntoNewThreddsMetadataBuilder( ThreddsMetadataBuilder source,
                                                                          ThreddsBuilderFactory builderFactory ); static ThreddsMetadataBuilder copyThreddsMetadataBuilder( ThreddsMetadataBuilder source,
                                                                   ThreddsMetadataBuilder recipient ); static ThreddsMetadataBuilder mergeTwoThreddsMetadata( ThreddsMetadataBuilder first,
                                                                ThreddsMetadataBuilder second,
                                                                ThreddsBuilderFactory builderFactory ); static void mergeTwoThreddsMetadata( ThreddsMetadataBuilder first,
                                              ThreddsMetadataBuilder second,
                                              ThreddsMetadataBuilder mergedResults ); }
ThreddsMetadataBuilderUtils { public static ThreddsMetadataBuilder copyThreddsMetadataBuilder( ThreddsMetadataBuilder source, ThreddsMetadataBuilder recipient ) { if ( source == null ) throw new IllegalArgumentException( "Source builder may not be null." ); if ( recipient == null ) throw new IllegalArgumentException( "Recipient builder may not be null."); if ( source.getCollectionType() != null ) recipient.setCollectionType( source.getCollectionType() ); if ( source.getDataFormat() != null ) recipient.setDataFormat( source.getDataFormat() ); recipient.setDataSizeInBytes( source.getDataSizeInBytes()); if ( source.getDataType() != null ) recipient.setDataType( source.getDataType() ); if ( source.getAvailableDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getAvailableDatePointBuilder(); recipient.setAvailableDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getCreatedDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getCreatedDatePointBuilder(); recipient.setCreatedDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getIssuedDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getIssuedDatePointBuilder(); recipient.setIssuedDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getMetadataCreatedDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getMetadataCreatedDatePointBuilder(); recipient.setMetadataCreatedDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getMetadataModifiedDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getMetadataModifiedDatePointBuilder(); recipient.setMetadataModifiedDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getModifiedDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getModifiedDatePointBuilder(); recipient.setModifiedDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } if ( source.getValidDatePointBuilder() != null ) { ThreddsMetadataBuilder.DatePointBuilder dpb = source.getValidDatePointBuilder(); recipient.setValidDatePointBuilder( dpb.getDate(), dpb.getDateFormat() ); } ThreddsMetadataBuilder.GeospatialCoverageBuilder geoCovBuilder = source.getGeospatialCoverageBuilder(); if ( geoCovBuilder != null ) if ( geoCovBuilder.getCRS() != null ) recipient.setNewGeospatialCoverageBuilder( geoCovBuilder.getCRS() ); if ( source.getTemporalCoverageBuilder() != null ) { ThreddsMetadataBuilder.DateRangeBuilder drb = source.getTemporalCoverageBuilder(); recipient.setTemporalCoverageBuilder( drb.getStartDate(), drb.getStartDateFormat(), drb.getEndDate(), drb.getEndDateFormat(), drb.getDuration(), drb.getResolution() ); } addCopiesOfContributorBuilders( source, recipient ); addCopiesOfCreatorBuilders( source, recipient ); addCopiesOfDocumentationBuilders( source, recipient ); addCopiesOfKeyphraseBuilders( source, recipient ); addCopiesOfProjectNameBuilders( source, recipient ); addCopiesOfPublisherBuilders( source, recipient ); addCopiesOfVariableGroupBuilders( source, recipient ); return recipient; } private  ThreddsMetadataBuilderUtils(); static ThreddsMetadataBuilder copyIntoNewThreddsMetadataBuilder( ThreddsMetadataBuilder source,
                                                                          ThreddsBuilderFactory builderFactory ); static ThreddsMetadataBuilder copyThreddsMetadataBuilder( ThreddsMetadataBuilder source,
                                                                   ThreddsMetadataBuilder recipient ); static ThreddsMetadataBuilder mergeTwoThreddsMetadata( ThreddsMetadataBuilder first,
                                                                ThreddsMetadataBuilder second,
                                                                ThreddsBuilderFactory builderFactory ); static void mergeTwoThreddsMetadata( ThreddsMetadataBuilder first,
                                              ThreddsMetadataBuilder second,
                                              ThreddsMetadataBuilder mergedResults );  }