Search in sources :

Example 11 with Person

use of model.Person in project compss by bsc-wdc.

the class Internal method testPSCOIn.

private static void testPSCOIn() {
    String id = "person_" + UUID.randomUUID().toString();
    Person p = new Person("PName1", 1, 1);
    p.makePersistent(id);
    System.out.println("Object p has id " + p.getID());
    InternalImpl.taskPSCOIn(p);
}
Also used : Person(model.Person)

Example 12 with Person

use of model.Person in project compss by bsc-wdc.

the class Internal method testMergeReduceTarget.

public static void testMergeReduceTarget() {
    // Init
    Person[] people = new Person[4];
    for (int i = 0; i < people.length; ++i) {
        String id = "person_" + UUID.randomUUID().toString();
        System.out.println("[LOG][PSCO_MR_TARGET] Person " + i + " BeginId = " + id);
        people[i] = new Person("PName" + i, i, i);
        people[i].makePersistent(id);
    }
    // Map
    for (int i = 0; i < people.length; ++i) {
        people[i].taskMap("NewName" + i);
    }
    // Reduce
    LinkedList<Integer> q = new LinkedList<Integer>();
    for (int i = 0; i < people.length; i++) {
        q.add(i);
    }
    int x = 0;
    while (!q.isEmpty()) {
        x = q.poll();
        int y;
        if (!q.isEmpty()) {
            y = q.poll();
            people[x].taskReduce(people[y]);
            q.add(x);
        }
    }
    // Get (sync) and write result
    Person p1 = people[0];
    String name = p1.getName();
    int age = p1.getAge();
    int numC = p1.getNumComputers();
    System.out.println("[LOG][PSCO_MR_TARGET] Person " + name + " with age " + age + " has " + numC + " computers");
    System.out.println("[LOG][PSCO_MR_TARGET] EndId = " + p1.getID());
}
Also used : Person(model.Person) LinkedList(java.util.LinkedList)

Example 13 with Person

use of model.Person in project compss by bsc-wdc.

the class InternalImpl method taskPSCOReturn.

public static Person taskPSCOReturn(String name, int age, int numC, String id) {
    Person p = new Person(name, age, numC);
    p.makePersistent(id);
    // Manually persist object to storage
    String pId = p.getID();
    p.deletePersistent();
    p.makePersistent(pId);
    return p;
}
Also used : Person(model.Person)

Example 14 with Person

use of model.Person in project kripton by xcesco.

the class PersonDaoImpl method selectById.

/**
 * <h2>Select SQL:</h2>
 *
 * <pre>SELECT id, name, age FROM person WHERE id = ${id}</pre>
 *
 * <h2>Projected columns:</h2>
 * <dl>
 * 	<dt>id</dt><dd>is associated to bean's property <strong>id</strong></dd>
 * 	<dt>name</dt><dd>is associated to bean's property <strong>name</strong></dd>
 * 	<dt>age</dt><dd>is associated to bean's property <strong>age</strong></dd>
 * </dl>
 *
 * <h2>Query's parameters:</h2>
 * <dl>
 * 	<dt>${id}</dt><dd>is binded to method's parameter <strong>id</strong></dd>
 * </dl>
 *
 * @param id
 * 	is binded to <code>${id}</code>
 * @return selected bean or <code>null</code>.
 */
@Override
public Person selectById(long id) {
    KriptonContentValues _contentValues = contentValues();
    // query SQL is statically defined
    String _sql = SELECT_BY_ID_SQL10;
    // add where arguments
    _contentValues.addWhereArgs(String.valueOf(id));
    String[] _sqlArgs = _contentValues.whereArgsAsArray();
    // log section BEGIN
    if (_context.isLogEnabled()) {
        // manage log
        Logger.info(_sql);
        // log for where parameters -- BEGIN
        int _whereParamCounter = 0;
        for (String _whereParamItem : _contentValues.whereArgs()) {
            Logger.info("==> param%s: '%s'", (_whereParamCounter++), StringUtils.checkSize(_whereParamItem));
        }
    // log for where parameters -- END
    }
    // log section END
    try (Cursor _cursor = database().rawQuery(_sql, _sqlArgs)) {
        // log section BEGIN
        if (_context.isLogEnabled()) {
            Logger.info("Rows found: %s", _cursor.getCount());
        }
        // log section END
        Person resultBean = null;
        if (_cursor.moveToFirst()) {
            int index0 = _cursor.getColumnIndex("id");
            int index1 = _cursor.getColumnIndex("name");
            int index2 = _cursor.getColumnIndex("age");
            resultBean = new Person();
            resultBean.id = _cursor.getLong(index0);
            if (!_cursor.isNull(index1)) {
                resultBean.name = _cursor.getString(index1);
            }
            if (!_cursor.isNull(index2)) {
                resultBean.age = _cursor.getInt(index2);
            }
        }
        return resultBean;
    }
}
Also used : KriptonContentValues(com.abubusoft.kripton.android.sqlite.KriptonContentValues) Cursor(android.database.Cursor) Person(sqlite.feature.many2many.case6.model.Person)

Example 15 with Person

use of model.Person in project BachelorPraktikum by lucasbuschlinger.

the class GooglePeople method getAllProfiles.

/**
 * Fetches the list of all profiles from the currently logged in user and passes them into the address book controller.
 */
public void getAllProfiles() {
    try {
        List<Person> persons = peopleService.people().connections().list("people/me").setPersonFields("names,addresses").setPageSize(PAGE_SIZE).execute().getConnections();
        for (Person p : persons) {
            if (p.getAddresses() != null) {
                Contact c = new Contact(p.getNames().get(0).getDisplayName(), p.getAddresses());
                AddressBook.getInstance().addContact(c);
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : IOException(java.io.IOException) Person(com.google.api.services.people.v1.model.Person) Contact(de.opendiabetes.vault.plugin.importer.googlecrawler.models.Contact)

Aggregations

Person (com.google.api.services.people.v1.model.Person)25 VCard (ezvcard.VCard)20 Test (org.junit.Test)16 EmailAddress (com.google.api.services.people.v1.model.EmailAddress)15 PhoneNumber (com.google.api.services.people.v1.model.PhoneNumber)13 Email (ezvcard.property.Email)13 Telephone (ezvcard.property.Telephone)13 Person (model.Person)13 List (java.util.List)12 Collectors (java.util.stream.Collectors)12 Name (com.google.api.services.people.v1.model.Name)11 StructuredName (ezvcard.property.StructuredName)11 Truth.assertThat (com.google.common.truth.Truth.assertThat)10 Pair (com.google.gdata.util.common.base.Pair)10 Collections (java.util.Collections)10 Function (java.util.function.Function)10 Address (com.google.api.services.people.v1.model.Address)9 Nullable (com.google.gdata.util.common.base.Nullable)8 Before (org.junit.Before)8 SOURCE_PARAM_NAME_TYPE (org.dataportabilityproject.datatransfer.google.common.GoogleStaticObjects.SOURCE_PARAM_NAME_TYPE)6