5c02af408f85baf0cc9ad7bb126c3af3eba4db24
[sdc.git] /
1 /*
2 * Copyright © 2016-2018 European Support Limited
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package org.openecomp.core.tools.store;
18
19 import com.datastax.driver.mapping.Result;
20 import com.datastax.driver.mapping.annotations.Accessor;
21 import com.datastax.driver.mapping.annotations.Query;
22 import com.datastax.driver.mapping.annotations.QueryParameters;
23 import org.openecomp.core.nosqldb.api.NoSqlDb;
24 import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
25 import org.openecomp.core.tools.store.zusammen.datatypes.VersionElementsEntity;
26
27 public class VersionElementsCassandraLoader {
28     private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
29     private static VersionElementsAccessor accessor = noSqlDb.getMappingManager().
30             createAccessor(VersionElementsAccessor.class);
31
32     public Result<VersionElementsEntity> listVersionElementsByPK(String space, String itemId, String versionId) {
33         return accessor.getByPK(space, itemId, versionId);
34     }
35
36     @Accessor
37     interface VersionElementsAccessor {
38
39         @Query("SELECT space, item_id, version_id, revision_id, element_ids " +
40                 "FROM zusammen_dox.version_elements WHERE space=? and item_id=? and version_id=?")
41
42         @QueryParameters(fetchSize = 400)
43         Result<VersionElementsEntity> getByPK(String space, String itemId, String versionId);
44     }
45 }