/** * Returns whether any information on the physical address is available. * * @returns <code>true</code>, if any physical information is available, <code>false</code> otherwise */ public boolean isPhysicalInfoAvailable() { return !getDeliveryPoint().isEmpty() || getCity() != null || getAdministrativeArea() != null || getPostalCode() != null || getCountry() != null; } }
private String getServiceUrl() { String url = getUrl; if ( provider != null && provider.getServiceContact() != null && provider.getServiceContact().getContactInfo() != null && provider.getServiceContact().getContactInfo().getOnlineResource() != null ) { url = provider.getServiceContact().getContactInfo().getOnlineResource().toExternalForm(); } return url; }
public static Address convertFromJAXB( AddressType ad ) { if ( ad == null ) { return null; } Address address = new Address(); address.setAdministrativeArea( ad.getAdministrativeArea() ); address.setCity( ad.getCity() ); address.setCountry( ad.getCountry() ); address.setPostalCode( ad.getPostalCode() ); address.setDeliveryPoint( ad.getDeliveryPoint() ); return address; }
writer.writeStartElement( WMSNS, "ContactInformation" ); if ( contact.getIndividualName() != null ) { writer.writeStartElement( WMSNS, "ContactPersonPrimary" ); writeElement( writer, WMSNS, "ContactPerson", contact.getIndividualName() ); writeElement( writer, WMSNS, "ContactOrganization", provider.getProviderName() ); writer.writeEndElement(); maybeWriteElementNS( writer, WMSNS, "ContactPosition", contact.getPositionName() ); final Address addr = contact.getContactInfo().getAddress(); if ( addr != null && addr.isPhysicalInfoAvailable() ) { writer.writeStartElement( WMSNS, "ContactAddress" ); writeElement( writer, WMSNS, "AddressType", "postal" ); for ( String s : addr.getDeliveryPoint() ) { maybeWriteElementNS( writer, WMSNS, "Address", s ); writeElement( writer, WMSNS, "City", addr.getCity() ); writeElement( writer, WMSNS, "StateOrProvince", addr.getAdministrativeArea() ); writeElement( writer, WMSNS, "PostCode", addr.getPostalCode() ); writeElement( writer, WMSNS, "Country", addr.getCountry() ); writer.writeEndElement(); contact.getContactInfo().getPhone().getVoice().get( 0 ) ); maybeWriteElementNS( writer, WMSNS, "ContactFacsimileTelephone", contact.getContactInfo().getPhone().getFacsimile().get( 0 ) ); if ( addr != null && !addr.getElectronicMailAddress().isEmpty() ) { maybeWriteElementNS( writer, WMSNS, "ContactElectronicMailAddress", addr.getElectronicMailAddress().get( 0 ) );
ContactInfo serviceContact = party.getContactInfo(); if ( serviceContact != null ) { writer.writeStartElement( owsNS, "ContactInfo" ); if ( serviceContact.getPhone() != null ) { writer.writeStartElement( owsNS, "Phone" ); if ( !serviceContact.getPhone().getVoice().isEmpty() ) { writeOptionalElement( writer, owsNS, "Voice", serviceContact.getPhone().getVoice().get( 0 ) ); if ( !serviceContact.getPhone().getFacsimile().isEmpty() ) { writeOptionalElement( writer, owsNS, "Facsimile", serviceContact.getPhone().getFacsimile().get( 0 ) ); Address address = serviceContact.getAddress(); if ( address != null ) { writer.writeStartElement( owsNS, "Address" ); exportSimpleStrings( writer, address.getDeliveryPoint(), owsNS, "DeliveryPoint" ); writeOptionalElement( writer, owsNS, "City", address.getCity() ); writeOptionalElement( writer, owsNS, "AdministrativeArea", address.getAdministrativeArea() ); writeOptionalElement( writer, owsNS, "PostalCode", address.getPostalCode() ); writeOptionalElement( writer, owsNS, "Country", address.getCountry() ); exportSimpleStrings( writer, address.getElectronicMailAddress(), owsNS, "ElectronicMailAddress" ); writer.writeEndElement(); if ( serviceContact.getOnlineResource() != null && !"".equals( serviceContact.getOnlineResource().toString().trim() ) ) { writer.writeAttribute( XLN_NS, "href", serviceContact.getOnlineResource().toString().trim() );
public static ResponsibleParty convertFromJAXB( ServiceContactType sc ) { if ( sc == null ) { return null; } ResponsibleParty res = new ResponsibleParty(); res.setIndividualName( sc.getIndividualName() ); res.setPositionName( sc.getPositionName() ); res.setRole( new CodeType( sc.getRole() ) ); ContactInfo info = new ContactInfo(); info.setContactInstructions( sc.getContactInstructions() ); info.setHoursOfService( sc.getHoursOfService() ); try { info.setOnlineResource( new URL( sc.getOnlineResource() ) ); } catch ( MalformedURLException e ) { // ignore this, schemas should be fixed so it already is an URL } Telephone phone = new Telephone(); phone.setFacsimile( Collections.singletonList( sc.getFacsimile() ) ); phone.setVoice( Collections.singletonList( sc.getPhone() ) ); info.setPhone( phone ); Address ad = convertFromJAXB( sc.getAddress() ); if ( ad != null ) { ad.setElectronicMailAddress( sc.getElectronicMailAddress() ); info.setAddress( ad ); } res.setContactInfo( info ); return res; }
/** * @param addressEl * context {@link OMElement} * @return an {@link Address} instance, never <code>null</code> */ protected Address parseAddress( OMElement addressEl ) { Address address = new Address(); XPath xpath = new XPath( "ows:DeliveryPoint", nsContext ); String[] deliveryPoints = getNodesAsStrings( addressEl, xpath ); for ( String deliveryPoint : deliveryPoints ) { address.getDeliveryPoint().add( deliveryPoint ); } xpath = new XPath( "ows:City", nsContext ); address.setCity( getNodeAsString( addressEl, xpath, null ) ); xpath = new XPath( "ows:AdministrativeArea", nsContext ); address.setAdministrativeArea( getNodeAsString( addressEl, xpath, null ) ); xpath = new XPath( "ows:PostalCode", nsContext ); address.setPostalCode( getNodeAsString( addressEl, xpath, null ) ); xpath = new XPath( "ows:Country", nsContext ); address.setCountry( getNodeAsString( addressEl, xpath, null ) ); xpath = new XPath( "ows:ElectronicMailAddress", nsContext ); String[] eMails = getNodesAsStrings( addressEl, xpath ); for ( int i = 0; i < eMails.length; i++ ) { address.getElectronicMailAddress().add( eMails[i] ); } return address; }
/** * @param contactInfoEl * context {@link OMElement} * @return an {@link ContactInfo} instance, never <code>null</code> */ protected ContactInfo parseContactInfo( OMElement contactInfoEl ) { ContactInfo contactInfo = new ContactInfo(); XPath xpath = new XPath( "ows:Phone", nsContext ); Telephone phone = parsePhone( getElement( contactInfoEl, xpath ) ); contactInfo.setPhone( phone ); xpath = new XPath( "ows:Address", nsContext ); OMElement addressEl = getElement( contactInfoEl, xpath ); contactInfo.setAddress( parseAddress( addressEl ) ); xpath = new XPath( "ows:OnlineResource/@xlink:href", nsContext ); contactInfo.setOnlineResource( getNodeAsURL( contactInfoEl, xpath, null ) ); xpath = new XPath( "ows:HoursOfService", nsContext ); contactInfo.setHoursOfService( getNodeAsString( contactInfoEl, xpath, null ) ); xpath = new XPath( "ows:ContactInstructions", nsContext ); contactInfo.setContactInstructions( getNodeAsString( contactInfoEl, xpath, null ) ); return contactInfo; }
/** * @param serviceContactEl * context {@link OMElement} * @return an {@link ResponsibleParty} instance, never <code>null</code> */ protected ResponsibleParty parseServiceContact( OMElement serviceContactEl ) { ResponsibleParty serviceContact = new ResponsibleParty(); XPath xpath = new XPath( "ows:IndividualName", nsContext ); serviceContact.setIndividualName( getNodeAsString( serviceContactEl, xpath, null ) ); xpath = new XPath( "ows:PositionName", nsContext ); serviceContact.setPositionName( getNodeAsString( serviceContactEl, xpath, null ) ); xpath = new XPath( "ows:ContactInfo", nsContext ); ContactInfo contactInfo = parseContactInfo( getElement( serviceContactEl, xpath ) ); serviceContact.setContactInfo( contactInfo ); xpath = new XPath( "ows:Role", nsContext ); OMElement roleEl = getElement( serviceContactEl, xpath ); if ( roleEl != null ) { serviceContact.setRole( parseCodeSpace( roleEl ) ); } return serviceContact; }
/** * @param phoneEl * context {@link OMElement} * @return an {@link Telephone} instance, never <code>null</code> */ protected Telephone parsePhone( OMElement phoneEl ) { Telephone phone = new Telephone(); XPath xpath = new XPath( "ows:Voice", nsContext ); String[] voices = getNodesAsStrings( phoneEl, xpath ); for ( int i = 0; i < voices.length; i++ ) { phone.getVoice().add( voices[i] ); } xpath = new XPath( "ows:Facsimile", nsContext ); String[] faxes = getNodesAsStrings( phoneEl, xpath ); for ( int i = 0; i < faxes.length; i++ ) { phone.getFacsimile().add( faxes[i] ); } return phone; }
writer.writeStartElement( owsNS, "ServiceContact" ); if ( serviceContact.getIndividualName() != null && !"".equals( serviceContact.getIndividualName().trim() ) ) { writeElement( writer, owsNS, "IndividualName", serviceContact.getIndividualName() ); if ( serviceContact.getPositionName() != null && !"".equals( serviceContact.getPositionName().trim() ) ) { writeElement( writer, owsNS, "PositionName", serviceContact.getPositionName() ); if ( serviceContact.getRole() != null ) { writeElement( writer, owsNS, "Role", serviceContact.getRole().getCode() );
writer.writeStartElement( "ContactInformation" ); if ( contact.getIndividualName() != null ) { writer.writeStartElement( "ContactPersonPrimary" ); writeElement( writer, "ContactPerson", contact.getIndividualName() ); writeElement( writer, "ContactOrganization", provider.getProviderName() ); writer.writeEndElement(); maybeWriteElement( writer, "ContactPosition", contact.getPositionName() ); final Address addr = contact.getContactInfo().getAddress(); if ( addr != null && addr.isPhysicalInfoAvailable() ) { writer.writeStartElement( "ContactAddress" ); writeElement( writer, "AddressType", "postal" ); for ( String s : addr.getDeliveryPoint() ) { maybeWriteElement( writer, "Address", s ); writeElement( writer, "City", addr.getCity() ); writeElement( writer, "StateOrProvince", addr.getAdministrativeArea() ); writeElement( writer, "PostCode", addr.getPostalCode() ); writeElement( writer, "Country", addr.getCountry() ); writer.writeEndElement(); contact.getContactInfo().getPhone().getVoice().get( 0 ) ); maybeWriteElement( writer, "ContactFacsimileTelephone", contact.getContactInfo().getPhone().getFacsimile().get( 0 ) ); if ( addr != null && !addr.getElectronicMailAddress().isEmpty() ) { maybeWriteElement( writer, "ContactElectronicMailAddress", addr.getElectronicMailAddress().get( 0 ) );
private String getServiceUrl() { String url = getUrl; if ( provider != null && provider.getServiceContact() != null && provider.getServiceContact().getContactInfo() != null && provider.getServiceContact().getContactInfo().getOnlineResource() != null ) { url = provider.getServiceContact().getContactInfo().getOnlineResource().toExternalForm(); } return url; }