2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright 2019 China Mobile
\r
6 *=================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
20 package org.onap.datalake.feeder.repository;
\r
22 import org.onap.datalake.feeder.domain.Topic;
\r
23 import org.springframework.beans.factory.annotation.Autowired;
\r
24 import org.springframework.data.couchbase.core.CouchbaseTemplate;
\r
26 import org.springframework.data.mongodb.MongoDbFactory;
\r
27 import org.springframework.data.mongodb.core.MongoTemplate;
\r
28 import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver;
\r
29 import org.springframework.data.mongodb.core.convert.DefaultMongoTypeMapper;
\r
30 import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
\r
31 import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
\r
32 import org.springframework.data.mongodb.core.query.Criteria;
\r
33 import org.springframework.data.mongodb.core.query.Query;
\r
34 import org.springframework.data.mongodb.core.query.Update;
\r
36 import com.mongodb.WriteResult;
\r
37 import com.mongodb.client.result.UpdateResult;
\r
39 import java.util.List;
\r
42 * @author Guobiao Mo
\r
45 public class TopicRepositoryImpl implements TopicRepositoryCustom {
\r
48 CouchbaseTemplate template;
\r
51 public long updateTopic(String topic, Boolean state) {
\r
53 Query query = new Query(Criteria.where("id").is(topic));
\r
54 Update update = new Update();
\r
55 update.set("state", state);
\r
57 UpdateResult result = mongoTemplate.updateFirst(query, update, Topic.class);
\r
60 return result.getModifiedCount();
\r