2 * Copyright © 2016-2018 European Support Limited
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.openecomp.core.tools.store;
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;
27 public class VersionElementsCassandraLoader {
28 private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
29 private static VersionElementsAccessor accessor = noSqlDb.getMappingManager().
30 createAccessor(VersionElementsAccessor.class);
32 public Result<VersionElementsEntity> listVersionElementsByPK(String space, String itemId, String versionId) {
33 return accessor.getByPK(space, itemId, versionId);
37 interface VersionElementsAccessor {
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=?")
42 @QueryParameters(fetchSize = 400)
43 Result<VersionElementsEntity> getByPK(String space, String itemId, String versionId);