if (interaction.isQueryStringCall()) {
mongoSpec.setCode(((QueryStringCall)interaction).getQueryString());
operation = MongoOperation.EVAL;
}
if (operation == null) {
throw new EISException("'" + OPERATION + "' property must be set on the query's interation.");
}
if (operation instanceof String) {
operation = MongoOperation.valueOf((String)operation);
}
mongoSpec.setOperation((MongoOperation)operation);
Object collection = interaction.getProperty(COLLECTION);
if (collection != null) {
mongoSpec.setCollection((String)collection);
}
// Allows setting of read preference as a property.
Object preference = interaction.getProperty(READ_PREFERENCE);
if (preference instanceof ReadPreference) {
mongoSpec.setReadPreference((ReadPreference)preference);
} else if (preference instanceof String) {
String constant = (String)preference;
if (constant.equals("PRIMARY")) {
mongoSpec.setReadPreference(ReadPreference.PRIMARY);
} else if (constant.equals("SECONDARY")) {
mongoSpec.setReadPreference(ReadPreference.SECONDARY );
} else {
throw new EISException("Invalid read preference property value: " + constant);
}
}
// Allows setting of write concern as a property.
Object concern = interaction.getProperty(WRITE_CONCERN);
if (concern instanceof WriteConcern) {
mongoSpec.setWriteConcern((WriteConcern)concern);
} else if (concern instanceof String) {
String constant = (String)concern;
if (constant.equals("FSYNC_SAFE")) {
mongoSpec.setWriteConcern(WriteConcern.FSYNC_SAFE);
} else if (constant.equals("JOURNAL_SAFE")) {
mongoSpec.setWriteConcern(WriteConcern.JOURNAL_SAFE);
} else if (constant.equals("MAJORITY")) {
mongoSpec.setWriteConcern(WriteConcern.MAJORITY);
} else if (constant.equals("NONE")) {
mongoSpec.setWriteConcern(WriteConcern.NONE);
} else if (constant.equals("NORMAL")) {
mongoSpec.setWriteConcern(WriteConcern.NORMAL);
} else if (constant.equals("REPLICAS_SAFE")) {
mongoSpec.setWriteConcern(WriteConcern.REPLICAS_SAFE);
} else if (constant.equals("SAFE")) {
mongoSpec.setWriteConcern(WriteConcern.SAFE);
} else {
throw new EISException("Invalid read preference property value: " + constant);
}
}
// Allows setting of options as a property.
Object options = interaction.getProperty(OPTIONS);