com.adaptrex.core.rest.RestService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of adaptrex-core Show documentation
Show all versions of adaptrex-core Show documentation
The Core Adaptrex Framework
/*
* Copyright 2012 Adaptrex, LLC
*
* 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 com.adaptrex.core.rest;
import javax.servlet.ServletContext;
import javax.ws.rs.core.UriInfo;
public class RestService {
private ServletContext context;
public RestService(ServletContext context) {
this.context = context;
}
/*
* Get Store
*/
public RestStore getStore(Class> clazz, UriInfo uriInfo) {
try {
return new RestStore(context, clazz, uriInfo);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public RestStore getStore(Class> clazz, UriInfo uriInfo, String factoryName) {
try {
return new RestStore(context, clazz, uriInfo, factoryName);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/*
* Get Model
*/
public RestModel getModel(Class> clazz, Object id, UriInfo uriInfo) {
return (new RestModel(context, clazz, uriInfo)).read(id);
}
public RestModel getModel(Class> clazz, Object id, UriInfo uriInfo, String factoryName) {
return (new RestModel(context, clazz, uriInfo, factoryName)).read(id);
}
public RestModel getModel(Class> clazz, String key, Object value, UriInfo uriInfo) {
return (new RestModel(context, clazz, uriInfo)).read(key, value);
}
public RestModel getModel(Class> clazz, String key, Object value, UriInfo uriInfo, String factoryName) {
return (new RestModel(context, clazz, uriInfo, factoryName)).read(key, value);
}
/*
* Create Model
*/
public RestModel createModel(Class> clazz, RequestBody modelData, UriInfo uriInfo) {
return (new RestModel(context, clazz, uriInfo)).create(modelData.getData());
}
public RestModel createModel(Class> clazz, RequestBody modelData, UriInfo uriInfo, String factoryName) {
return (new RestModel(context, clazz, uriInfo, factoryName)).create(modelData.getData());
}
/*
* Update Model
*/
public RestModel updateModel(Class> clazz, Object id, RequestBody modelData, UriInfo uriInfo) {
return (new RestModel(context, clazz, uriInfo)).update(id, modelData.getData());
}
public RestModel updateModel(Class> clazz, Object id, RequestBody modelData, UriInfo uriInfo, String factoryName) {
return (new RestModel(context, clazz, uriInfo, factoryName)).update(id, modelData.getData());
}
public RestModel updateModel(Class> clazz, String key, Object value, RequestBody modelData, UriInfo uriInfo) {
return (new RestModel(context, clazz, uriInfo)).update(key, value, modelData.getData());
}
public RestModel updateModel(Class> clazz, String key, Object value, RequestBody modelData, UriInfo uriInfo, String factoryName) {
return (new RestModel(context, clazz, uriInfo, factoryName)).update(key, value, modelData.getData());
}
/*
* Delete Model
*/
public RestModel deleteModel(Class> clazz, Object id) {
return (new RestModel(context, clazz)).delete(id);
}
public RestModel deleteModel(Class> clazz, Object id, String factoryName) {
return (new RestModel(context, clazz, factoryName)).delete(id);
}
public RestModel deleteModel(Class> clazz, String key, Object value) {
return (new RestModel(context, clazz)).delete(key, value);
}
public RestModel deleteModel(Class> clazz, String key, Object value, String factoryName) {
return (new RestModel(context, clazz, factoryName)).delete(key, value);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy