public void createCorruptionFlagsIndexes() { mongoTemplate .indexOps(Release.class) .ensureIndex(new Index().on(FlagsConstants.I038_VALUE, Direction.ASC)); mongoTemplate .indexOps(Release.class) .ensureIndex(new Index().on(FlagsConstants.I003_VALUE, Direction.ASC)); mongoTemplate .indexOps(Release.class) .ensureIndex(new Index().on(FlagsConstants.I007_VALUE, Direction.ASC)); }
public void createMandatoryImportIndexes() { // vietnam specific indexes mongoTemplate .indexOps(Release.class) .ensureIndex(new Index().on("planning.budget.projectID", Direction.ASC)); mongoTemplate .indexOps(Release.class) .ensureIndex(new Index().on("planning.bidNo", Direction.ASC)); mongoTemplate .indexOps(Organization.class) .ensureIndex(new Index().on("identifier._id", Direction.ASC)); mongoTemplate .indexOps(Organization.class) .ensureIndex(new Index().on("additionalIdentifiers._id", Direction.ASC)); mongoTemplate.indexOps(Organization.class).ensureIndex(new Index().on("types", Direction.ASC)); mongoTemplate .indexOps(Organization.class) .ensureIndex(new Index().on("name", Direction.ASC).unique()); mongoTemplate .indexOps(VNLocation.class) .ensureIndex(new Index().on("description", Direction.ASC)); mongoTemplate .indexOps(Release.class) .ensureIndex(new Index().on("tender.contrMethod.details", Direction.ASC)); logger.info("Added mandatory Mongo indexes"); }
@Bean(name = "mongoTemplate") public MongoTemplate getMongoTemplate() throws UnknownHostException, MongoException { MongoTemplate template = new MongoTemplate( new MongoClient( env.getProperty("smartcampus.vas.web.mongo.host"), Integer.parseInt(env.getProperty("smartcampus.vas.web.mongo.port"))), "carpooling"); template.indexOps(Travel.class).ensureIndex(new GeospatialIndex("from.coordinates")); template.indexOps(Travel.class).ensureIndex(new GeospatialIndex("to.coordinates")); template.indexOps(Community.class).ensureIndex(new GeospatialIndex("zone.coordinates")); return template; }
@Before public void setUp() { // clear all collections mongoTemplate.dropCollection("role"); mongoTemplate.dropCollection("userAccount"); // see UserAccount.username definition: @Indexed does not work, but this does (sdm // 1.1.1.RELEASE) // see RepositoryTest.userDuplicate() mongoTemplate .indexOps(UserAccount.class) .ensureIndex(new Index().on("username", Order.DESCENDING).unique(Duplicates.DROP)); // establish roles userRole = new Role(); userRole.setId("ROLE_USER"); mongoTemplate.insert(userRole, "role"); adminRole = new Role(); adminRole.setId("ROLE_ADMIN"); mongoTemplate.insert(adminRole, "role"); superAdminRole = new Role(); superAdminRole.setId("ROLE_SUPERADMIN"); mongoTemplate.insert(superAdminRole, "role"); }
private void createCollection(String collectionName) { mongoTemplate.createCollection(collectionName); IndexDefinition index = new CompoundIndexDefinition(new BasicDBObject().append("m_tag", 1)).unique(); mongoTemplate.indexOps(collectionName).ensureIndex(index); }
private void createProcuringEntityIndexes() { mongoTemplate .indexOps(Release.class) .ensureIndex(new Index().on("tender.procuringEntity._id", Direction.ASC)); mongoTemplate .indexOps(Release.class) .ensureIndex(new Index().on("tender.procuringEntity.group._id", Direction.ASC)); mongoTemplate .indexOps(Release.class) .ensureIndex(new Index().on("tender.procuringEntity.department._id", Direction.ASC)); mongoTemplate .indexOps(Release.class) .ensureIndex(new Index().on("tender.procuringEntity.address.postalCode", Direction.ASC)); mongoTemplate .indexOps(City.class) .ensureIndex(new TextIndexDefinitionBuilder().onField("name").onField("id").build()); mongoTemplate .indexOps(OrgDepartment.class) .ensureIndex(new TextIndexDefinitionBuilder().onField("name").onField("id").build()); mongoTemplate .indexOps(OrgGroup.class) .ensureIndex(new TextIndexDefinitionBuilder().onField("name").onField("id").build()); }
public void createPostImportStructures() { createCorruptionFlagsIndexes(); // initialize some extra indexes mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("ocid", Direction.ASC)); 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("tender.tenderPeriod.startDate", Direction.ASC)); mongoTemplate .indexOps(Release.class) .ensureIndex(new Index().on("tender.tenderPeriod.endDate", 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("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(); } }