de.mhus.lib.xdb.XdbService Maven / Gradle / Ivy
/**
* Copyright (C) 2020 Mike Hummel ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.mhus.lib.xdb;
import java.util.List;
import de.mhus.lib.adb.DbCollection;
import de.mhus.lib.adb.QueryParser;
import de.mhus.lib.adb.query.AQuery;
import de.mhus.lib.basics.Adaptable;
import de.mhus.lib.core.pojo.PojoModelFactory;
import de.mhus.lib.errors.MException;
import de.mhus.lib.errors.NotFoundException;
public interface XdbService extends Adaptable {
boolean isConnected();
List getTypeNames();
XdbType getType(String name) throws NotFoundException;
String getSchemaName();
// String getDataSourceName();
void updateSchema(boolean cleanup) throws MException;
void connect() throws Exception;
default T getObjectByQualification(AQuery query) throws MException {
@SuppressWarnings("unchecked")
XdbType type = (XdbType) getType(query.getType());
return type.getObjectByQualification(query);
}
default DbCollection getByQualification(AQuery query) throws MException {
@SuppressWarnings("unchecked")
XdbType type = (XdbType) getType(query.getType());
return type.getByQualification(query);
}
default DbCollection getAll(Class type) throws MException {
XdbType xType = (XdbType) getType(type);
return xType.getAll();
}
default long count(AQuery query) throws MException {
@SuppressWarnings("unchecked")
XdbType type = (XdbType) getType(query.getType());
return type.count(query);
}
XdbType getType(Class type) throws NotFoundException;
T inject(T object);
T getObject(Class clazz, Object... keys) throws MException;
PojoModelFactory getPojoModelFactory();
String getDataSourceName();
void delete(Object object) throws MException;
void save(Object object) throws MException;
QueryParser createParser();
}