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 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; }