예제 #1
0
 /**
  * 删除内存中的对象的公用方法
  *
  * @param delIdS
  * @param custNo
  * @param sessCustNo
  * @param sessConstant
  * @throws ClassNotFoundException
  * @throws IllegalAccessException
  * @throws InstantiationException
  */
 @SuppressWarnings("unchecked")
 public void deleteSessionObj(
     String delIdS,
     int custNo,
     String sessCustNo,
     SessionConstant sessConstant,
     String className) {
   String delIdStr = ServletActionContext.getRequest().getParameter(delIdS);
   System.out.println("delIdStr: " + delIdStr);
   if (StringUtils.isNotEmpty(delIdStr)) {
     String[] strs = delIdStr.split(",");
     List<String> delIdList = Arrays.asList(strs);
     Map<String, Object> map = null;
     // 取得session中的map
     System.out.println("custNo, sessCustNo: " + custNo + ", " + sessCustNo);
     map = SessionUtil.getRow(sessConstant.value(), custNo, sessCustNo);
     System.out.println("Map; " + map);
     if (map == null) {
       map = new HashMap<String, Object>();
     }
     for (String str : delIdList) {
       if (StringUtils.isNumeric(str)) {
         if (map != null && map.containsKey(str)) {
           T dto = (T) map.get(str);
           dto.setOperationType(OperationType.DEL);
           map.put(str, dto);
         } else {
           T dto = null;
           try {
             dto = (T) Class.forName(className).newInstance();
           } catch (InstantiationException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
           } catch (IllegalAccessException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
           } catch (ClassNotFoundException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
           }
           dto.setOperationType(OperationType.DEL);
           map.put(str, dto);
         }
       } else {
         map.remove(str);
       }
     }
     System.out.println("map: " + map);
     SessionUtil.insertRow(sessConstant.value(), custNo, sessCustNo, map);
   }
 }
예제 #2
0
    @Override
    public void load(final Runnable onSuccess, final ICallback<Pair<String, Throwable>> onFailure) {
      CourseSelection courseSelection = session.get(CourseSelection.class);
      CourseAndCourseRegistration[] courseRegList =
          session.get(CourseAndCourseRegistration[].class);

      // See if the logged-in user is an instructor in the selected course
      if (!isInstructor(courseSelection, courseRegList)) {
        // Special case: logged-in user isn't an instructor.
        session.add(new User[0]);
        onSuccess.run();
        return;
      }

      // Load users in course.
      SessionUtil.loadUsersInCourse(
          page,
          courseSelection,
          new ICallback<User[]>() {
            @Override
            public void call(User[] value) {
              // Success!
              session.add(value);
              onSuccess.run();
            }
          },
          new ICallback<Pair<String, Throwable>>() {
            @Override
            public void call(Pair<String, Throwable> value) {
              onFailure.call(value);
            }
          });
    }
예제 #3
0
 public void valueUnbound(HttpSessionBindingEvent pinsEvent) {
   SessionUtil.setNowUser(-1);
   Log.info(
       " <SESSIONLOGINID> <DELETED FROM SESSION> <LOGIN_ID:"
           + loginId_
           + "><SESSION_ID:"
           + sessionId_
           + ">");
 }
예제 #4
0
  @Test
  public void VirtualProperties() {
    MiniRepository repository = new MiniRepository();
    Session session = SessionUtil.openSession(repository, Party.class, Person.class);

    // Persistence
    session.save(new Person("John", "Doe"));
    List<STMT> statements =
        IteratorAdapter.asList(
            repository.findStatements(null, new UID(TEST.NS, "displayName"), null, null, false));
    assertEquals(1, statements.size());
    STMT stmt = statements.get(0);
    assertEquals("John Doe", stmt.getObject().getValue());

    // Retrieval
    session = SessionUtil.openSession(repository, Party.class, Person.class);
    Person person = session.findInstances(Person.class).get(0);
    assertEquals("John Doe", person.getDisplayName());
  }
예제 #5
0
 @Override
 public void load(final Runnable onSuccess, final ICallback<Pair<String, Throwable>> onFailure) {
   SessionUtil.loadCourseAndCourseRegistrationList(
       page,
       new ICallback<CourseAndCourseRegistration[]>() {
         @Override
         public void call(CourseAndCourseRegistration[] value) {
           session.add(value);
           onSuccess.run();
         }
       },
       onFailure);
 }
예제 #6
0
 public ResponsePage getData(
     HashMap criteria, int offset, int pageSize, String orderBy, String orderDirection)
     throws Exception {
   SkillTypesCriteria cr = null;
   if (criteria != null) {
     cr = new SkillTypesCriteria(criteria);
   }
   SessionUtil.setAttribute(
       "SkillTypesCriteria", cr); // store in session, reuse in later when coming back
   PaginationRequest request = new PaginationRequest(offset, pageSize, orderBy, orderDirection);
   PaginationResponse response = DaoFactory.process(DaoFactory.NAME.SkillTypesDAO, cr, request);
   List lst = response.convertRowsToClasses(org.mlink.iwm.bean.SkillType.class);
   return new ResponsePage(response.getTotalCount(), lst);
 }
예제 #7
0
 @Override
 public void load(final Runnable onSuccess, final ICallback<Pair<String, Throwable>> onFailure) {
   // No page param is required, since we assume that the Problem
   // is already in the session.
   SessionUtil.loadProblemAndTestCaseList(
       page,
       session.get(Problem.class),
       new ICallback<ProblemAndTestCaseList>() {
         public void call(ProblemAndTestCaseList value) {
           session.add(value);
           onSuccess.run();
         }
       },
       onFailure);
 }
예제 #8
0
 public void valueBound(HttpSessionBindingEvent pinsEvent) {
   SessionUtil.setNowUser(1);
   Log.info(" <SESSIONLISTENER> <CREATED> <SESSIONID:" + loginId_ + ">");
 }