d9300a007b46f9f2d625bc32dfbc6f73b34e947f
[sdc.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.versioning.dao.impl;
22
23 import org.openecomp.core.dao.UniqueValueDaoFactory;
24 import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
25 import org.openecomp.sdc.versioning.dao.VersionableEntityDao;
26 import org.openecomp.sdc.versioning.dao.VersionableEntityDaoFactory;
27 import org.openecomp.sdc.versioning.types.VersionableEntityStoreType;
28
29 public class VersionableEntityDaoFactoryImpl extends VersionableEntityDaoFactory {
30   private static VersionableEntityDao CASSANDRA_INSTANCE = new VersionableEntityDaoCassandraImpl(
31       UniqueValueDaoFactory.getInstance().createInterface());
32   private static VersionableEntityDao ZUSAMMEN_INSTANCE =
33       new VersionableEntityDaoZusammenImpl(ZusammenAdaptorFactory.getInstance().createInterface());
34
35   @Override
36   public VersionableEntityDao createInterface() {
37     throw new UnsupportedOperationException
38         ("Please use createInterface api with VersionableEntityStoreType argument.");
39   }
40
41   @Override
42   public VersionableEntityDao createInterface(VersionableEntityStoreType storeType) {
43     switch (storeType) {
44       case Cassandra:
45         return CASSANDRA_INSTANCE;
46       case Zusammen:
47         return ZUSAMMEN_INSTANCE;
48       default:
49         throw new IllegalArgumentException("Unssported state store");
50     }
51   }
52 }