Search in sources :

Example 1 with ServerRuntime

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();
    }
}
Also used : CayenneDataObject(org.apache.cayenne.CayenneDataObject) ServerRuntime(org.apache.cayenne.configuration.server.ServerRuntime) CayenneDataObject(org.apache.cayenne.CayenneDataObject) ObjectContext(org.apache.cayenne.ObjectContext) Map(java.util.Map)

Example 2 with ServerRuntime

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();
}
Also used : SelectQuery(org.apache.cayenne.query.SelectQuery) Employee(jp.co.nexus.crm.db.Employee) Expression(org.apache.cayenne.exp.Expression) ServerRuntime(org.apache.cayenne.configuration.server.ServerRuntime) List(java.util.List) ObjectContext(org.apache.cayenne.ObjectContext)

Example 3 with ServerRuntime

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();
}
Also used : ServerRuntime(org.apache.cayenne.configuration.server.ServerRuntime) BeforeClass(org.junit.BeforeClass)

Example 4 with ServerRuntime

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);
}
Also used : ServletConfig(javax.servlet.ServletConfig) HttpServlet(javax.servlet.http.HttpServlet) WebUtil(org.apache.cayenne.configuration.web.WebUtil) ServletException(javax.servlet.ServletException) Collection(java.util.Collection) HttpServletResponse(javax.servlet.http.HttpServletResponse) RemoteSession(org.apache.cayenne.remote.RemoteSession) Module(org.apache.cayenne.di.Module) IOException(java.io.IOException) ROPServerModule(org.apache.cayenne.configuration.rop.server.ROPServerModule) CayenneRuntime(org.apache.cayenne.configuration.CayenneRuntime) HttpServletRequest(javax.servlet.http.HttpServletRequest) Map(java.util.Map) ServletContext(javax.servlet.ServletContext) ClientMessage(org.apache.cayenne.remote.ClientMessage) WebConfiguration(org.apache.cayenne.configuration.web.WebConfiguration) RemoteService(org.apache.cayenne.remote.RemoteService) ServerRuntime(org.apache.cayenne.configuration.server.ServerRuntime) RemoteService(org.apache.cayenne.remote.RemoteService) ServerRuntime(org.apache.cayenne.configuration.server.ServerRuntime) Module(org.apache.cayenne.di.Module) ROPServerModule(org.apache.cayenne.configuration.rop.server.ROPServerModule) WebConfiguration(org.apache.cayenne.configuration.web.WebConfiguration)

Example 5 with ServerRuntime

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();
}
Also used : ServerRuntime(org.apache.cayenne.configuration.server.ServerRuntime) BeforeClass(org.junit.BeforeClass)

Aggregations

ServerRuntime (org.apache.cayenne.configuration.server.ServerRuntime)15 ObjectContext (org.apache.cayenne.ObjectContext)6 Employee (jp.co.nexus.crm.db.Employee)3 Module (org.apache.cayenne.di.Module)3 BeforeClass (org.junit.BeforeClass)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 List (java.util.List)2 Map (java.util.Map)2 CustomerListBean (jp.co.nexus.crm.bean.CustomerListBean)2 Area (jp.co.nexus.crm.db.Area)2 NCCalldoc (jp.co.nexus.crm.db.NCCalldoc)2 NCCustomer (jp.co.nexus.crm.db.NCCustomer)2 NCDivision (jp.co.nexus.crm.db.NCDivision)2 NCPerson (jp.co.nexus.crm.db.NCPerson)2 ROPServerModule (org.apache.cayenne.configuration.rop.server.ROPServerModule)2 WebConfiguration (org.apache.cayenne.configuration.web.WebConfiguration)2 Expression (org.apache.cayenne.exp.Expression)2 SelectQuery (org.apache.cayenne.query.SelectQuery)2 RemoteService (org.apache.cayenne.remote.RemoteService)2