var contact = new Contact({ phone: request.phone, status: request.status }); // Convert the Model instance to a simple object using Model's 'toObject' function // to prevent weirdness like infinite looping... var upsertData = contact.toObject(); // Delete the _id property, otherwise Mongo will return a "Mod on _id not allowed" error delete upsertData._id; // Do the upsert, which works like this: If no Contact document exists with // _id = contact.id, then create a new doc using upsertData. // Otherwise, update the existing doc with upsertData Contact.update({_id: contact.id}, upsertData, {upsert: true}, function(err{...});
Account account = new Account(); Contact contact = new Contact(); account.addToContact(contact); em.persist(account); em.flush(); assertNotNull(account.getId()); assertNotNull(account.getContacts().get(0).getId()); assertEquals(1, account.getContacts().size()); account.removeFromContact(contact); em.merge(account); em.flush(); assertEquals(0, account.getContacts().size());
@Document(collection = "user") @TypeAlias("user") @CompoundIndexes({ @CompoundIndex(name = "contact_email", def = "{ 'contact.mail': 1 }", unique = true) }) public class User { @Id private ObjectId id; private Contact info = new Contact(); }
public static void main(String[] args) { ApplicationContext context = AnnotationConfigApplicationContext("se.hsr.web") ContactDAO cd = (ContactDAO)context.getBean("contactDAOImpl"); Contact contact = new Contact(); contact.setFirstname("Zorro"); cd.addContact(contact); }
@Test public void testVersionInfoComponent() throws URISyntaxException { Contact contact = new Contact().name("TestName").email("test@test.de"); Swagger2MarkupConverter.Context context = createContext(); MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder(); markupDocBuilder = new ContactInfoComponent(context).apply(markupDocBuilder, ContactInfoComponent.parameters( contact, OverviewDocument.SECTION_TITLE_LEVEL)); markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8); Path expectedFile = getExpectedFile(COMPONENT_NAME); DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME)); } }
public class Lista1Activity extends ListActivity { ArrayList<Contact> lista; ArrayAdapter<Contact> adaptor; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); lista = new ArrayList<Contact>(); adaugaContact("Florian", "Iancu"); adaugaContact("Ioana", "Constantina"); adaptor = new ArrayAdapter<String>(this, R.layout.list_item, lista); setListAdapter(adaptor); } public void adaugaContact(String nume, String prenume) { lista.add(new Contact(nume, prenume)); adaptor.notifyDataSetChanged(); } }
private Contact convertContact(io.swagger.annotations.Contact contactAnnotation) { Contact contact = new Contact(); contact.setName(contactAnnotation.name()); contact.setUrl(contactAnnotation.url()); contact.setEmail(contactAnnotation.email()); return contact; }
public void serializationBoon(){ Contact contact = new Contact() contact.name = 'John' contact.registration = Date.parse('dd/MM/yyyy', '20/10/2011') ObjectMapper mapper = JsonFactory.create() String jsonData = mapper.toJson(contact) println(jsonData) Contact reloadContact = mapper.fromJson(jsonData, Contact.class) }
var newContact = new Contact({ name: req.body.name, email: req.body.email, number: req.body.number });
private Contact from(io.swagger.annotations.Contact contactAnnotation) { Contact contact = new Contact() .name(emptyToNull(contactAnnotation.name())) .email(emptyToNull(contactAnnotation.email())) .url(emptyToNull(contactAnnotation.url())); if (contact.getName() == null && contact.getEmail() == null && contact.getUrl() == null) { contact = null; } return contact; }
class ContactManager { List<Contact> contacts = new ArrayList<>(); public List<Contact> contacts() { return Collection.unmodifiableList(contacts); } public void addContact(String name) { contacts.add(new Contact(name)); } }
while(in.hasNextLine()){ String line= in.nextLine(); String[] tokens = line.split(" "); this.contactList.add(new Contact(tokens[0], tokens[1], tokens[2], tokens[3],tokens[4])) }
.version(ServiceStarter.RAKAM_VERSION) .description("An analytics platform API that lets you create your own analytics services.") .contact(new Contact().email("contact@rakam.io")) .license(new License() .name("Apache License 2.0")
public void getAllContacts(ContentResolver cr) { Cursor phones = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null); while (phones.moveToNext()) { long id = phones.getLong(phones.getColumnIndex(ContactsContract.Data._ID)); String name = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)); String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); nameList.add(name); phoneList.add(phoneNumber); contactList.add(new Contact(id, name, phoneNumber)); } phones.close(); }
sorma = SORMA.getInstance(getBaseContext(), AddressBookContentProvider.class); // insert contact Contact contact = new Contact(); contact.setFirstName("fname1"); contact.setLastName("lname1"); sorma.insert(contact);
Contact contact = new Contact(); contact.setUserId("adarshk"); contact.setFullName("Adarsh"); contact.setImageURL("R.drawable.applozic_ic_contact_picture_holo_light"); contact.setEmailId("contact@applozic.com");
private Info getInfo() { Info info = new Info(); Contact contact = new Contact(); contact.setName(serviceTemplate.getMetadata().get(BluePrintConstants.METADATA_TEMPLATE_AUTHOR)); info.setContact(contact); info.setTitle(serviceTemplate.getMetadata().get(BluePrintConstants.METADATA_TEMPLATE_NAME)); info.setDescription(serviceTemplate.getDescription()); info.setVersion(serviceTemplate.getMetadata().get(BluePrintConstants.METADATA_TEMPLATE_VERSION)); return info; }
public class TestDataFactory { private static Contact createContact(Long contactUserId) { Contact contact = new Contact(); contact.setContactUserId(contactUserId); contact.setPrincipleUserId(LocalStorageBuilder.principalUserId); contact.setUserStatus(UserStatus.ONLINE); contact.setAddedTimeStamp(1410168552386L); contact.setVisible(true); return contact; } }
private Contact convertContact(io.swagger.annotations.Contact contactAnnotation) { Contact contact = new Contact(); contact.setName(contactAnnotation.name()); contact.setUrl(contactAnnotation.url()); contact.setEmail(contactAnnotation.email()); return contact; }