use of org.springframework.data.mongodb.core.script.ExecutableMongoScript in project ocvn by devgateway.
the class MongoTemplateConfiguration method createPostImportStructures.
public void createPostImportStructures() {
createCorruptionFlagsIndexes();
// initialize some extra indexes
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("ocid", Direction.ASC).unique());
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.procurementMethod", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.procurementMethodRationale", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.status", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("awards.status", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("awards.suppliers._id", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("awards.date", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("awards.publishedDate", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("awards.value.amount", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.value.amount", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.contrMethod._id", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.numberOfTenderers", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.cancellationRationale", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.submissionMethod", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.publicationMethod", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.TENDER_PERIOD_START_DATE, Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.TENDER_PERIOD_END_DATE, Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.items.classification._id", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.items.deliveryLocation._id", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.items.deliveryLocation.geometry.coordinates", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("planning.budget.projectLocation.geometry.coordinates", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("planning.budget.projectLocation._id", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.items.deliveryLocation.geometry.coordinates", Direction.ASC));
mongoTemplate.indexOps(Organization.class).ensureIndex(new TextIndexDefinitionBuilder().onField("name").onField("id").onField("additionalIdentifiers._id").build());
mongoTemplate.indexOps(VNLocation.class).ensureIndex(new TextIndexDefinitionBuilder().onField("description").onField("uri").build());
//vietnam specific indexes:
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("planning.bidPlanProjectDateApprove", Direction.ASC));
createProcuringEntityIndexes();
logger.info("Added extra Mongo indexes");
ScriptOperations scriptOps = mongoTemplate.scriptOps();
// add script to calculate the percentiles endpoint
URL scriptFile = getClass().getResource("/tenderBidPeriodPercentilesMongo.js");
try {
String scriptText = IOUtils.toString(scriptFile);
ExecutableMongoScript script = new ExecutableMongoScript(scriptText);
scriptOps.register(new NamedMongoScript("tenderBidPeriodPercentiles", script));
} catch (IOException e) {
e.printStackTrace();
}
// add general mongo system helper methods
URL systemScriptFile = getClass().getResource("/mongoSystemScripts.js");
try {
String systemScriptFileText = IOUtils.toString(systemScriptFile);
ExecutableMongoScript script = new ExecutableMongoScript(systemScriptFileText);
scriptOps.execute(script);
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.springframework.data.mongodb.core.script.ExecutableMongoScript in project ocvn by devgateway.
the class VNImportService method purgeDatabase.
/**
* Delete all data without dropping indexes
*/
private void purgeDatabase() {
logMessage("Purging database...");
ScriptOperations scriptOps = mongoTemplate.scriptOps();
ExecutableMongoScript echoScript = new ExecutableMongoScript("db.dropDatabase()");
scriptOps.execute(echoScript);
logMessage("Database purged.");
// //recreate inline indexes
// mongoTemplate.setApplicationContext(applicationContext);
//
// create indexes that affect import performance
mongoTemplateConfiguration.createMandatoryImportIndexes();
}
use of org.springframework.data.mongodb.core.script.ExecutableMongoScript in project spring-data-mongodb by spring-projects.
the class DefaultScriptOperationsUnitTests method saveShouldGenerateScriptNameForExecutableMongoScripts.
// DATAMONGO-479
@Test
public void saveShouldGenerateScriptNameForExecutableMongoScripts() {
scriptOps.register(new ExecutableMongoScript("function..."));
ArgumentCaptor<NamedMongoScript> captor = ArgumentCaptor.forClass(NamedMongoScript.class);
verify(mongoOperations, times(1)).save(captor.capture(), eq("system.js"));
Assert.assertThat(captor.getValue().getName(), notNullValue());
}
use of org.springframework.data.mongodb.core.script.ExecutableMongoScript in project oc-explorer by devgateway.
the class AbstractMongoDatabaseConfiguration method createPostImportStructures.
public void createPostImportStructures() {
createCorruptionFlagsIndexes();
// initialize some extra indexes
getTemplate().indexOps(Release.class).ensureIndex(new Index().on("ocid", Direction.ASC).unique());
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.TENDER_PROC_METHOD, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on("tender.procurementMethodRationale", Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.TENDER_STATUS, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.AWARDS_STATUS, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.AWARDS_SUPPLIERS_ID, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.AWARDS_SUPPLIERS_NAME, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.AWARDS_DATE, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.AWARDS_VALUE_AMOUNT, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.TENDER_VALUE_AMOUNT, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.TENDER_NO_TENDERERS, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.TENDER_SUBMISSION_METHOD, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.TENDER_PERIOD_START_DATE, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.TENDER_PERIOD_END_DATE, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on("tender.items.classification._id", Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on("tender.items.deliveryLocation._id", Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on("tender.items.deliveryLocation.geometry.coordinates", Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.BIDS_DETAILS_TENDERERS_ID, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.BIDS_DETAILS_VALUE_AMOUNT, Direction.ASC));
getTemplate().indexOps(Organization.class).ensureIndex(new TextIndexDefinitionBuilder().withDefaultLanguage(MongoConstants.MONGO_LANGUAGE).onField("name").onField("id").onField("additionalIdentifiers._id").build());
getTemplate().indexOps(Release.class).ensureIndex(new TextIndexDefinitionBuilder().named("text_search").withDefaultLanguage(MongoConstants.MONGO_LANGUAGE).onFields("tender.title", "tender.description", "tender.procuringEntity.name", "tender.id", "tender.procuringEntity.description", "awards.id", "awards.description", "awards.suppliers.name", "awards.suppliers.description", "ocid", "buyer.name", "buyer.id").build());
getLogger().info("Added extra Mongo indexes");
ScriptOperations scriptOps = getTemplate().scriptOps();
// add script to calculate the percentiles endpoint
URL scriptFile = getClass().getResource("/tenderBidPeriodPercentilesMongo.js");
try {
String scriptText = IOUtils.toString(scriptFile);
ExecutableMongoScript script = new ExecutableMongoScript(scriptText);
scriptOps.register(new NamedMongoScript("tenderBidPeriodPercentiles", script));
} catch (IOException e) {
e.printStackTrace();
}
// add general mongo system helper methods
URL systemScriptFile = getClass().getResource("/mongoSystemScripts.js");
try {
String systemScriptFileText = IOUtils.toString(systemScriptFile);
ExecutableMongoScript script = new ExecutableMongoScript(systemScriptFileText);
scriptOps.execute(script);
} catch (IOException e) {
e.printStackTrace();
}
}
Aggregations