Search in sources :

Example 6 with Contact

use of com.google.api.ads.admanager.axis.v202202.Contact in project arctic-sea by 52North.

the class RelatedPartyTypeDecoder method parseContact.

private Contact parseContact(RelatedPartyType rpt) throws DecodingException {
    ContactType ct = rpt.getContact().getContact();
    Contact contact = new Contact();
    contact.setAddress(parseAddress(ct));
    contact.setContactInstructions(parseContactInstructions(ct));
    contact.setElectronicMailAddress(parseElectronicMailAddress(ct));
    contact.setTelephoneFacsimile(parseTelephoneFacsimile(ct));
    contact.setTelephoneVoice(parseTelephoneVoice(ct));
    contact.setWebsite(parseWebsite(ct));
    return contact;
}
Also used : ContactType(eu.europa.ec.inspire.schemas.base2.x20.ContactType) Contact(org.n52.shetland.inspire.base2.Contact)

Example 7 with Contact

use of com.google.api.ads.admanager.axis.v202202.Contact in project tests by datanucleus.

the class RelationshipsTest method testOneToManyBidirMappedByDotNotation.

/**
 * Test of 1-N bidir with element having embedded PC, and 1-1 bidir with embedded PC, and using "mappedBy" with DOT notation.
 */
public void testOneToManyBidirMappedByDotNotation() {
    try {
        EntityManager em = getEM();
        EntityTransaction tx = em.getTransaction();
        try {
            tx.begin();
            Contact c1 = new Contact("John Doe");
            Document d1 = new Document("Doc1", c1);
            Document d2 = new Document("Doc2", c1);
            c1.setMainDocument(d1);
            d1.getDetails().setOwner(c1);
            c1.getDocuments().add(d2);
            d2.getDetails().setOwner(c1);
            em.persist(c1);
            em.persist(d1);
            em.persist(d2);
            Contact c2 = new Contact("Jane Dose");
            em.persist(c2);
            tx.commit();
        } catch (Exception e) {
            e.printStackTrace();
            fail("Exception thrown while creating data");
        } finally {
            if (tx.isActive()) {
                tx.rollback();
            }
            em.close();
        }
        // Query the datastore and check the results
        em = getEM();
        tx = em.getTransaction();
        List<Document> documents = null;
        try {
            tx.begin();
            TypedQuery<Document> query = em.createQuery("SELECT d FROM Document d JOIN FETCH d.details.owner owner_1 WHERE d.name = 'Doc2'", Document.class);
            documents = query.getResultList();
            tx.commit();
        } catch (Exception e) {
            e.printStackTrace();
            fail("Exception thrown while retrieving data");
        } finally {
            if (tx.isActive()) {
                tx.rollback();
            }
            em.close();
        }
        assertEquals(1, documents.size());
        assertEquals("Doc2", documents.get(0).getName());
        assertEquals("John Doe", documents.get(0).getDetails().getOwner().getName());
        em = getEM();
        tx = em.getTransaction();
        try {
            tx.begin();
            // Null out the relations
            TypedQuery<Contact> query = em.createQuery("SELECT c FROM " + Contact.class.getName() + " c", Contact.class);
            List<Contact> contacts = query.getResultList();
            for (Contact c : contacts) {
                c.setMainDocument(null);
                c.getDocuments().clear();
            }
            tx.commit();
        } catch (Exception e) {
            e.printStackTrace();
            fail("Exception thrown while retrieving data");
        } finally {
            if (tx.isActive()) {
                tx.rollback();
            }
            em.close();
        }
    } finally {
        clean(Contact.class);
        clean(Document.class);
    }
}
Also used : EntityTransaction(javax.persistence.EntityTransaction) EntityManager(javax.persistence.EntityManager) Document(org.datanucleus.samples.annotations.one_many.bidir_3.Document) Contact(org.datanucleus.samples.annotations.one_many.bidir_3.Contact)

Example 8 with Contact

use of com.google.api.ads.admanager.axis.v202202.Contact in project arctic-sea by 52North.

the class EReportingHeaderEncoderTest method testValidity.

@Test
public void testValidity() throws XMLStreamException, OwsExceptionReport, SAXException, MalformedURLException, IOException, URISyntaxException, EncodingException {
    EReportingHeader header = new EReportingHeader().setInspireID(new Identifier("id", "namespace").setVersionId(Nillable.missing())).setChange(new EReportingChange("Changed because... you know")).setReportingPeriod(Referenceable.of(Nillable.present(new TimeInstant(DateTime.now())))).setReportingAuthority(new RelatedParty().setIndividualName(Nillable.missing()).setOrganisationName("Organisation").setPositionName("Postionti").addRole(new Reference().setHref(URI.create("http://hallo"))).addRole(Nillable.withheld()).setContact(new Contact().addTelephoneFacsimile("1234").addTelephoneFacsimile(Nillable.missing()).addTelephoneVoice("asdfasdf").setHoursOfService(new PT_FreeText().addTextGroup(new LocalisedCharacterString("asdfasdf"))).setWebsite(Nillable.unknown()).setElectronicMailAddress(Nillable.unknown()).setAddress(new AddressRepresentation().setPostCode("12341234").setAddressFeature(new Reference().setHref(URI.create("http://asdfasdf"))).addLocatorDesignator("localtor").addAddressArea(Nillable.withheld()).addAddressArea(new GeographicalName().setGrammaticalGender(new CodeType("a", new URI("b"))).setGrammaticalNumber(new CodeType("c", new URI("d"))).setLanguage("eng").setNativeness(new CodeType("<asdfasdf")).setNameStatus(Nillable.unknown()).addSpelling(new Spelling().setScript("asdfasdf").setText("asdfasdf").setTransliterationScheme("asdfasdfasdf")).setPronunciation(new Pronunciation().setIPA("asdfasdf").setSoundLink(URI.create("http://asdfasdf")))).addAdminUnit(new GeographicalName().setGrammaticalGender(new CodeType("a", new URI("b"))).setGrammaticalNumber(new CodeType("c", new URI("d"))).setLanguage("eng").setNativeness(new CodeType("<asdfasdf")).setNameStatus(Nillable.unknown()).addSpelling(new Spelling().setScript("asdfasdf").setText("asdfasdf").setTransliterationScheme("asdfasdfasdf")).setPronunciation(new Pronunciation().setIPA("asdfasdf").setSoundLink(URI.create("http://asdfasdf")))).addPostName(Nillable.withheld()).addPostName(new GeographicalName().setGrammaticalGender(new CodeType("a", new URI("b"))).setGrammaticalNumber(new CodeType("c", new URI("d"))).setLanguage("eng").setNativeness(new CodeType("<asdfasdf")).setNameStatus(Nillable.unknown()).addSpelling(new Spelling().setScript("asdfasdf").setText("asdfasdf").setTransliterationScheme("asdfasdfasdf")).setPronunciation(new Pronunciation().setIPA("asdfasdf").setSoundLink(URI.create("http://asdfasdf")))).addThoroughfare(Nillable.withheld()).addThoroughfare(new GeographicalName().setGrammaticalGender(new CodeType("a", new URI("b"))).setGrammaticalNumber(new CodeType("c", new URI("d"))).setLanguage("eng").setNativeness(new CodeType("<asdfasdf")).setNameStatus(Nillable.unknown()).addSpelling(new Spelling().setScript("asdfasdf").setText("asdfasdf").setTransliterationScheme("asdfasdfasdf")).setPronunciation(new Pronunciation().setIPA("asdfasdf").setSoundLink(URI.create("http://asdfasdf")))))));
    validate(header);
}
Also used : LocalisedCharacterString(org.n52.shetland.iso.gmd.LocalisedCharacterString) Spelling(org.n52.shetland.inspire.Spelling) Pronunciation(org.n52.shetland.inspire.Pronunciation) Reference(org.n52.shetland.w3c.xlink.Reference) PT_FreeText(org.n52.shetland.iso.gmd.PT_FreeText) URI(java.net.URI) Contact(org.n52.shetland.inspire.base2.Contact) Identifier(org.n52.shetland.inspire.base.Identifier) EReportingHeader(org.n52.shetland.aqd.EReportingHeader) AddressRepresentation(org.n52.shetland.inspire.ad.AddressRepresentation) GeographicalName(org.n52.shetland.inspire.GeographicalName) RelatedParty(org.n52.shetland.inspire.base2.RelatedParty) CodeType(org.n52.shetland.ogc.gml.CodeType) EReportingChange(org.n52.shetland.aqd.EReportingChange) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) Test(org.junit.Test)

Example 9 with Contact

use of com.google.api.ads.admanager.axis.v202202.Contact in project arctic-sea by 52North.

the class ReportingHeaderReaderTest method testValidity.

@Test
public void testValidity() throws Exception {
    EReportingHeader header = new EReportingHeader().setInspireID(new Identifier("id", "namespace").setVersionId(Nillable.missing())).setChange(new EReportingChange("Changed because... you know")).setReportingPeriod(Referenceable.of(Nillable.present(new TimeInstant(DateTime.now())))).setReportingAuthority(new RelatedParty().setIndividualName(Nillable.missing()).setOrganisationName("Organisation").setPositionName("Postionti").addRole(new Reference().setHref(URI.create("http://hallo"))).addRole(Nillable.withheld()).setContact(new Contact().addTelephoneFacsimile("1234").addTelephoneFacsimile(Nillable.missing()).addTelephoneVoice("asdfasdf").setHoursOfService(new PT_FreeText().addTextGroup(new LocalisedCharacterString("asdfasdf"))).setWebsite(Nillable.unknown()).setElectronicMailAddress(Nillable.unknown()).setAddress(new AddressRepresentation().setPostCode("12341234").setAddressFeature(new Reference().setHref(URI.create("http://asdfasdf"))).addLocatorDesignator("localtor").addAddressArea(Nillable.withheld()).addAddressArea(new GeographicalName().setGrammaticalGender(new CodeType("a", new URI("b"))).setGrammaticalNumber(new CodeType("c", new URI("d"))).setLanguage("eng").setNativeness(new CodeType("<asdfasdf")).setNameStatus(Nillable.unknown()).addSpelling(new Spelling().setScript("asdfasdf").setText("asdfasdf").setTransliterationScheme("asdfasdfasdf")).setPronunciation(new Pronunciation().setIPA("asdfasdf").setSoundLink(URI.create("http://asdfasdf")))).addAdminUnit(new GeographicalName().setGrammaticalGender(new CodeType("a", new URI("b"))).setGrammaticalNumber(new CodeType("c", new URI("d"))).setLanguage("eng").setNativeness(new CodeType("<asdfasdf")).setNameStatus(Nillable.unknown()).addSpelling(new Spelling().setScript("asdfasdf").setText("asdfasdf").setTransliterationScheme("asdfasdfasdf")).setPronunciation(new Pronunciation().setIPA("asdfasdf").setSoundLink(URI.create("http://asdfasdf")))).addPostName(Nillable.withheld()).addPostName(new GeographicalName().setGrammaticalGender(new CodeType("a", new URI("b"))).setGrammaticalNumber(new CodeType("c", new URI("d"))).setLanguage("eng").setNativeness(new CodeType("<asdfasdf")).setNameStatus(Nillable.unknown()).addSpelling(new Spelling().setScript("asdfasdf").setText("asdfasdf").setTransliterationScheme("asdfasdfasdf")).setPronunciation(new Pronunciation().setIPA("asdfasdf").setSoundLink(URI.create("http://asdfasdf")))).addThoroughfare(Nillable.withheld()).addThoroughfare(new GeographicalName().setGrammaticalGender(new CodeType("a", new URI("b"))).setGrammaticalNumber(new CodeType("c", new URI("d"))).setLanguage("eng").setNativeness(new CodeType("<asdfasdf")).setNameStatus(Nillable.unknown()).addSpelling(new Spelling().setScript("asdfasdf").setText("asdfasdf").setTransliterationScheme("asdfasdfasdf")).setPronunciation(new Pronunciation().setIPA("asdfasdf").setSoundLink(URI.create("http://asdfasdf")))))));
    try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
        new EReportingHeaderEncoder(EncodingContext.of(EncoderFlags.ENCODER_REPOSITORY, new EncoderRepository()), baos, header).write();
        ByteArrayInputStream in = new ByteArrayInputStream(baos.toByteArray());
        EReportingHeader read = new ReportingHeaderReader().read(in);
        errors.checkThat(read.getChange(), is(equalTo(header.getChange())));
        errors.checkThat(read.getContent(), is(equalTo(header.getContent())));
        errors.checkThat(read.getDelete(), is(equalTo(header.getDelete())));
        errors.checkThat(read.getInspireID(), is(equalTo(header.getInspireID())));
        errors.checkThat(read.getReportingPeriod(), is(equalTo(header.getReportingPeriod())));
        errors.checkThat(read.getReportingAuthority(), is(equalTo(header.getReportingAuthority())));
        errors.checkThat(read.getReportingAuthority().getIndividualName(), is(header.getReportingAuthority().getIndividualName()));
        errors.checkThat(read.getReportingAuthority().getOrganisationName().get(), is(header.getReportingAuthority().getOrganisationName().get()));
        errors.checkThat(read.getReportingAuthority().getPositionName().get(), is(header.getReportingAuthority().getPositionName().get()));
        Contact c1 = read.getReportingAuthority().getContact().get();
        Contact c2 = header.getReportingAuthority().getContact().get();
        errors.checkThat(c1, is(c2));
        errors.checkThat(c1.getContactInstructions(), is(c2.getContactInstructions()));
        errors.checkThat(c1.getElectronicMailAddress(), is(c2.getElectronicMailAddress()));
        errors.checkThat(c1.getHoursOfService().get(), is(c2.getHoursOfService().get()));
        errors.checkThat(c1.getTelephoneFacsimile(), is(c2.getTelephoneFacsimile()));
        errors.checkThat(c1.getTelephoneVoice(), is(c2.getTelephoneVoice()));
        errors.checkThat(c1.getWebsite(), is(c2.getWebsite()));
        AddressRepresentation a1 = c1.getAddress().get();
        AddressRepresentation a2 = c2.getAddress().get();
        errors.checkThat(a1.getAddressAreas(), is(a2.getAddressAreas()));
        errors.checkThat(a1.getAddressFeature(), is(a2.getAddressFeature()));
        errors.checkThat(a1.getAdminUnits(), is(a2.getAdminUnits()));
        errors.checkThat(a1.getLocatorDesignators(), is(a2.getLocatorDesignators()));
        errors.checkThat(a1.getLocatorNames(), is(a2.getLocatorNames()));
        errors.checkThat(a1.getPostCode(), is(a2.getPostCode()));
        errors.checkThat(a1.getPostNames(), is(a2.getPostNames()));
        errors.checkThat(a1.getThoroughfares(), is(a2.getThoroughfares()));
    } catch (Exception e) {
        errors.addError(e);
    }
}
Also used : LocalisedCharacterString(org.n52.shetland.iso.gmd.LocalisedCharacterString) Spelling(org.n52.shetland.inspire.Spelling) Pronunciation(org.n52.shetland.inspire.Pronunciation) Reference(org.n52.shetland.w3c.xlink.Reference) EncoderRepository(org.n52.svalbard.encode.EncoderRepository) PT_FreeText(org.n52.shetland.iso.gmd.PT_FreeText) ByteArrayOutputStream(java.io.ByteArrayOutputStream) URI(java.net.URI) Contact(org.n52.shetland.inspire.base2.Contact) Identifier(org.n52.shetland.inspire.base.Identifier) ByteArrayInputStream(java.io.ByteArrayInputStream) ReportingHeaderReader(org.n52.svalbard.read.ReportingHeaderReader) EReportingHeader(org.n52.shetland.aqd.EReportingHeader) AddressRepresentation(org.n52.shetland.inspire.ad.AddressRepresentation) GeographicalName(org.n52.shetland.inspire.GeographicalName) RelatedParty(org.n52.shetland.inspire.base2.RelatedParty) CodeType(org.n52.shetland.ogc.gml.CodeType) EReportingChange(org.n52.shetland.aqd.EReportingChange) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) Test(org.junit.Test)

Example 10 with Contact

use of com.google.api.ads.admanager.axis.v202202.Contact in project googleads-java-lib by googleads.

the class UpdateContacts method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param contactId the ID of the contact to update.
 * @throws ApiException if the API request failed with one or more service errors.
 * @throws RemoteException if the API request failed due to other errors.
 */
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session, long contactId) throws RemoteException {
    // Get the ContactService.
    ContactServiceInterface contactService = adManagerServices.get(session, ContactServiceInterface.class);
    // Create a statement to only select a single contact by ID.
    StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", contactId);
    // Get the contact.
    ContactPage page = contactService.getContactsByStatement(statementBuilder.toStatement());
    Contact contact = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
    // Update the address of the contact.
    contact.setAddress("123 New Street, New York, NY, 10011");
    // Update the contact on the server.
    Contact[] contacts = contactService.updateContacts(new Contact[] { contact });
    for (Contact updatedContact : contacts) {
        System.out.printf("Contact with ID %d, name '%s', and address '%s' was updated.%n", updatedContact.getId(), updatedContact.getName(), updatedContact.getAddress());
    }
}
Also used : StatementBuilder(com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder) ContactPage(com.google.api.ads.admanager.axis.v202108.ContactPage) ContactServiceInterface(com.google.api.ads.admanager.axis.v202108.ContactServiceInterface) Contact(com.google.api.ads.admanager.axis.v202108.Contact)

Aggregations

Contact (com.google.api.ads.admanager.axis.v202108.Contact)4 ContactServiceInterface (com.google.api.ads.admanager.axis.v202108.ContactServiceInterface)4 Contact (com.google.api.ads.admanager.axis.v202111.Contact)4 ContactServiceInterface (com.google.api.ads.admanager.axis.v202111.ContactServiceInterface)4 Contact (com.google.api.ads.admanager.axis.v202202.Contact)4 ContactServiceInterface (com.google.api.ads.admanager.axis.v202202.ContactServiceInterface)4 Contact (org.n52.shetland.inspire.base2.Contact)4 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)3 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)3 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)3 ContactPage (com.google.api.ads.admanager.axis.v202108.ContactPage)3 ContactPage (com.google.api.ads.admanager.axis.v202111.ContactPage)3 ContactPage (com.google.api.ads.admanager.axis.v202202.ContactPage)3 Random (java.util.Random)3 AddressRepresentation (org.n52.shetland.inspire.ad.AddressRepresentation)3 URI (java.net.URI)2 Test (org.junit.Test)2 EReportingChange (org.n52.shetland.aqd.EReportingChange)2 EReportingHeader (org.n52.shetland.aqd.EReportingHeader)2 GeographicalName (org.n52.shetland.inspire.GeographicalName)2