List of usage examples for org.springframework.data.mongodb.core MongoTemplate insert
@Override
public <T> ExecutableInsert<T> insert(Class<T> domainType)
From source file:com.github.ffremont.microservices.springboot.manager.stores.ValidPropertiesStore.java
public static void provide(MongoTemplate mongoTemplate) { mongoTemplate.insert(new Property("toto", "fr", "myValue")); mongoTemplate.insert(new Property("totoBis", "fr.ffremont", "myValueBis")); mongoTemplate.insert(new Property("totoBisToto", "fr.ffremont.toto", "myValueBis")); mongoTemplate.insert(new Property("totoCom", "com.ffremont", "myValueCom")); }
From source file:com.github.ffremont.microservices.springboot.manager.stores.ValidMicroServiceStore.java
public static void provide(MongoTemplate mongoTemplate) { MicroService ms = new MicroService(); ms.setCluster("myCluster"); ms.setNode("myNodeA"); ms.setGav(new Gav("fr.ffremont", "myArtifact", null, "0.0.1")); ms.setName("toto"); ms.setNsProperties("fr.ffremont.toto"); mongoTemplate.insert(ms); }
From source file:curly.artifactory.ArtifactoryTestHelper.java
public static Artifact createArtifact(MongoTemplate mongoTemplate) { mongoTemplate.findAllAndRemove(new Query(), Artifact.class); Artifact artifact = new Artifact(); Set<Language> languages = new HashSet<>(0); Set<Tag> tags = new HashSet<>(0); tags.add(new Tag("document")); tags.add(new Tag("nosql")); languages.add(new Language("java")); languages.add(new Language("groovy")); languages.add(new Language("ruby")); languages.add(new Language("scala")); languages.add(new Language("javascript")); artifact.setName("curly"); artifact.setDescription("a hobby project"); artifact.setAuthor("joaoevangelista"); artifact.setCategory(new Category("database")); artifact.setHomePage("http://example.com"); artifact.setIncubation(LocalDate.now().toString()); artifact.setLanguages(languages);//from www . ja v a2s . c o m artifact.setTags(tags); artifact.setOwner("6969"); mongoTemplate.insert(artifact); Assert.assertTrue(artifact.getId() != null); try { System.out.println(new ObjectMapper().writeValueAsString(artifact)); } catch (JsonProcessingException e) { e.printStackTrace(); } return artifact; }
From source file:io.curly.tagger.TagHelper.java
public Tag createTag(MongoTemplate mongoTemplate) { mongoTemplate.findAllAndRemove(new Query(), Tag.class); Tag tag = new Tag(null, "love"); mongoTemplate.insert(tag); Assert.notNull(tag.getId(), "Must be generate!"); return tag;/* w w w .ja v a 2 s .c om*/ }
From source file:curly.artifactory.SpringBootTest.java
public Artifact createArtifact(MongoTemplate mongoTemplate) { Artifact artifact = new Artifact(); Set<Language> languages = new HashSet<>(0); Set<Type> types = new HashSet<>(0); types.add(new Type("document")); types.add(new Type("nosql")); languages.add(new Language("java")); languages.add(new Language("groovy")); languages.add(new Language("ruby")); artifact.setName("A lovers project"); artifact.setAuthor("joaoevangelista"); artifact.setCategory(new Category("database")); artifact.setHomePage("http://example.com"); artifact.setIncubation(LocalDate.now().toString()); artifact.setLanguages(languages);/*from ww w . j a va 2s .c o m*/ artifact.setTypes(types); mongoTemplate.insert(artifact); return artifact; }