use of org.apache.cayenne.configuration.server.ServerRuntime in project CRMWebApp by jshioya0506.
the class Object2DBTable method registerdTable.
/**
* テーブルにデータを登録する
* @param tableName テーブル名
* @param dataMaps データマップ
*/
public void registerdTable(String tableName, List<Map<String, Object>> dataMaps) {
// DBの設定情報を取得
ServerRuntime cayenneRuntime = new ServerRuntime("cayenne-NexusCRM.xml");
ObjectContext context = cayenneRuntime.getContext();
// テーブルオブジェクトにデータを設定し、テーブルにデータを登録
for (Map<String, Object> dataMap : dataMaps) {
// データ登録対象のテーブルオブジェクトを取得
CayenneDataObject dataObj = CayenneDataObjectUtil.findDataObject(context, tableName);
// テーブルオブジェクトにデータを設定
for (Map.Entry<String, Object> entry : dataMap.entrySet()) {
dataObj.writeProperty(entry.getKey(), entry.getValue());
}
// データ登録
context.commitChanges();
}
}
use of org.apache.cayenne.configuration.server.ServerRuntime in project CRMWebApp by jshioya0506.
the class AuthFacade method doLogin.
/**
* 認証処理
* @param userId ログインID(=メールアドレス)
* @param password パスワード
* @return 正常に処理された場合はtrue、そうでない場合はfalse
*/
public boolean doLogin(String userId, String password) {
// DBの設定情報を取得
ServerRuntime cayenneRuntime = new ServerRuntime("cayenne-NexusCRM.xml");
ObjectContext context = cayenneRuntime.getContext();
// 職員テーブルの検索条件を作成[検索条件:メールアドレスとパスワードが一致すること]
Expression qureyExpr = ExpressionFactory.matchExp(Employee.EMAIL_PROPERTY, userId);
qureyExpr = qureyExpr.andExp(ExpressionFactory.matchExp(Employee.PASSWORD_PROPERTY, password));
SelectQuery query = new SelectQuery(Employee.class);
query.setQualifier(qureyExpr);
// 従業員検索
List<Employee> employees = (List<Employee>) context.performQuery(query);
return !employees.isEmpty();
}
use of org.apache.cayenne.configuration.server.ServerRuntime in project tutorials by eugenp.
the class CayenneAdvancedOperationTests method setupTheCayenneContext.
@BeforeClass
public static void setupTheCayenneContext() {
ServerRuntime cayenneRuntime = ServerRuntime.builder().addConfig("cayenne-project.xml").build();
context = cayenneRuntime.newContext();
}
use of org.apache.cayenne.configuration.server.ServerRuntime in project cayenne by apache.
the class ROPServlet method init.
@Override
public void init(ServletConfig configuration) throws ServletException {
checkAlreadyConfigured(configuration.getServletContext());
this.servletContext = configuration.getServletContext();
WebConfiguration configAdapter = new WebConfiguration(configuration);
String configurationLocation = configAdapter.getConfigurationLocation();
Map<String, String> eventBridgeParameters = configAdapter.getOtherParameters();
Collection<Module> modules = configAdapter.createModules();
ServerRuntime runtime = ServerRuntime.builder().addConfig(configurationLocation).addModules(modules).addModule(binder -> ROPServerModule.contributeROPBridgeProperties(binder).putAll(eventBridgeParameters)).build();
this.remoteService = runtime.getInjector().getInstance(RemoteService.class);
this.serializationService = runtime.getInjector().getInstance(ROPSerializationService.class);
WebUtil.setCayenneRuntime(servletContext, runtime);
super.init(configuration);
}
use of org.apache.cayenne.configuration.server.ServerRuntime in project cayenne by apache.
the class DefaultValueTransformerFactoryIT method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
ServerRuntime runtime = ServerRuntime.builder().addConfig("cayenne-crypto.xml").build();
t1 = runtime.getChannel().getEntityResolver().getDbEntity("TABLE1");
t2 = runtime.getChannel().getEntityResolver().getDbEntity("TABLE2");
t3 = runtime.getChannel().getEntityResolver().getDbEntity("TABLE3");
t5 = runtime.getChannel().getEntityResolver().getDbEntity("TABLE5");
dbToBytes = getDefaultDbConverters();
objectToBytes = getDefaultObjectConverters();
}
Aggregations