use of edu.umass.cs.gnsclient.client.util.BasicGuidEntry in project GNS by MobilityFirst.
the class ContextAwareGroupGuidExample method showFieldValuesInGuids.
//
// private helper methods
//
/**
* Prints out the values of fields name field in the guids given in the guids list.
*
* @param guids
* @param field
* @throws Exception
*/
private static void showFieldValuesInGuids(JSONArray guids, String field) throws Exception {
for (int i = 0; i < guids.length(); i++) {
BasicGuidEntry guidInfo = new BasicGuidEntry(client.lookupGuidRecord(guids.getString(i)));
GuidEntry entry = GuidUtils.lookupGuidEntryFromDatabase(client, guidInfo.getEntityName());
String value = client.fieldRead(entry, field);
System.out.println(guids.get(i).toString() + ": " + field + " -> " + value);
}
}
use of edu.umass.cs.gnsclient.client.util.BasicGuidEntry in project GNS by MobilityFirst.
the class ContextAwareGroupGuidExample method cleanupAllGuids.
/**
* Removes all the sub guids we use in this example.
*
* @throws Exception
*/
private static void cleanupAllGuids() throws Exception {
// Remove the two group guids
client.guidRemove(masterGuid, groupOneGuidEntry.getGuid());
client.guidRemove(masterGuid, groupTwoGuidEntry.getGuid());
// Remove all the value holding guids
String query = "~" + fieldName + " : {$exists: true}";
JSONArray result = client.selectQuery(query);
for (int i = 0; i < result.length(); i++) {
BasicGuidEntry guidInfo = new BasicGuidEntry(client.lookupGuidRecord(result.getString(i)));
GuidEntry guidEntry = GuidUtils.lookupGuidEntryFromDatabase(client, guidInfo.getEntityName());
client.guidRemove(masterGuid, guidEntry.getGuid());
}
}
use of edu.umass.cs.gnsclient.client.util.BasicGuidEntry in project GNS by MobilityFirst.
the class ServerIntegrationTest method test_561_QueryLookupSecondGroup.
/**
* Check to see if the second group has members now... it should.
*
* @param groupTestFieldName
* @param groupTwoGuid
*/
public void test_561_QueryLookupSecondGroup(String groupTestFieldName, GuidEntry groupTwoGuid) {
if (!enable552) {
return;
}
try {
JSONArray result = clientCommands.selectLookupGroupQuery(groupTwoGuid.getGuid());
// should be 4 now
Assert.assertThat(result.length(), Matchers.equalTo(4));
// look up the individual values
for (int i = 0; i < result.length(); i++) {
BasicGuidEntry guidInfo = new BasicGuidEntry(clientCommands.lookupGuidRecord(result.getString(i)));
GuidEntry entry = GuidUtils.lookupGuidEntryFromDatabase(clientCommands, guidInfo.getEntityName());
String value = clientCommands.fieldReadArrayFirstElement(entry, groupTestFieldName);
Assert.assertEquals("0", value);
}
} catch (Exception e) {
failWithStackTrace("Exception executing selectLookupGroupQuery: ", e);
}
}
use of edu.umass.cs.gnsclient.client.util.BasicGuidEntry in project GNS by MobilityFirst.
the class ServerIntegrationTest method test_560_QueryLookupGroupAfterAlterations.
/**
* Lookup the group members again after the change.
*
* @param groupTestFieldName
* @param groupOneGuid
*/
public void test_560_QueryLookupGroupAfterAlterations(String groupTestFieldName, GuidEntry groupOneGuid) {
if (!enable552) {
return;
}
try {
JSONArray result = clientCommands.selectLookupGroupQuery(groupOneGuid.getGuid());
// should only be one
Assert.assertThat(result.length(), Matchers.equalTo(1));
// look up the individual values
for (int i = 0; i < result.length(); i++) {
BasicGuidEntry guidInfo = new BasicGuidEntry(clientCommands.lookupGuidRecord(result.getString(i)));
GuidEntry entry = GuidUtils.lookupGuidEntryFromDatabase(clientCommands, guidInfo.getEntityName());
String value = clientCommands.fieldReadArrayFirstElement(entry, groupTestFieldName);
Assert.assertEquals(TEST_HIGH_VALUE, value);
}
} catch (Exception e) {
failWithStackTrace("Exception executing selectLookupGroupQuery: ", e);
}
}
use of edu.umass.cs.gnsclient.client.util.BasicGuidEntry in project GNS by MobilityFirst.
the class ServerIntegrationTest method test_559_QueryAlterGroup.
/**
* Change the value that the group is triggered on.
*
* @param groupTestFieldName
* @param groupOneGuid
*/
// Change all the testQuery fields except 1 to be equal to zero
public void test_559_QueryAlterGroup(String groupTestFieldName, GuidEntry groupOneGuid) {
if (!enable552) {
return;
}
try {
JSONArray result = clientCommands.selectLookupGroupQuery(groupOneGuid.getGuid());
// change ALL BUT ONE to be ZERO
for (int i = 0; i < result.length() - 1; i++) {
BasicGuidEntry guidInfo = new BasicGuidEntry(clientCommands.lookupGuidRecord(result.getString(i)));
GuidEntry entry = GuidUtils.lookupGuidEntryFromDatabase(clientCommands, guidInfo.getEntityName());
JSONArray array = new JSONArray(Arrays.asList(0));
clientCommands.fieldReplaceOrCreateList(entry, groupTestFieldName, array);
}
} catch (Exception e) {
failWithStackTrace("Exception while trying to alter the fields: ", e);
}
}
Aggregations