コード例 #1
0
/** 社外アドレスユーザーの情報をJSONデータとして出力するクラスです。 <br> */
public class AddressBookUserLiteJSONScreen extends ALJSONScreen {

  /** logger */
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(AddressBookUserLiteJSONScreen.class.getName());

  @Override
  protected String getJSONString(RunData rundata, Context context) throws Exception {
    String result = "";
    JSONArray json;

    try {

      String mode = rundata.getParameters().getString("mode");
      if ("group".equals(mode)) {
        String groupname = rundata.getParameters().getString("groupname");

        json =
            JSONArray.fromObject(
                AddressBookUserUtils.getAddressBookUserLiteBeansFromGroup(
                    groupname, ALEipUtils.getUserId(rundata)));
      } else {
        json = new JSONArray();
      }
      result = json.toString();
    } catch (Exception e) {
      logger.error("AddressBookUserLiteJSONScreen.getJSONString", e);
    }

    return result;
  }
}
コード例 #2
0
/** タイムカードの一覧を処理するクラスです。 <br> */
public class ExtTimecardListScreen extends ExtTimecardScreen {

  /** logger */
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(ExtTimecardListScreen.class.getName());

  /**
   * @param rundata
   * @param context
   * @throws Exception
   */
  @Override
  protected void doOutput(RunData rundata, Context context) throws Exception {

    try {
      ExtTimecardSelectData listData = new ExtTimecardSelectData();
      listData.initField();
      listData.setRowsNum(100);
      listData.doViewList(this, rundata, context);

      String layout_template = "portlets/html/ja/ajax-exttimecard-list.vm";
      setTemplate(rundata, context, layout_template);

    } catch (Exception ex) {
      logger.error("[ExtTimecardListScreen] Exception.", ex);
      ALEipUtils.redirectDBError(rundata);
    }
  }
}
コード例 #3
0
public class PortletFeatureLiteJSONScreen extends ALJSONScreen {

  /** logger */
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(PortletFeatureLiteJSONScreen.class.getName());

  @Override
  protected String getJSONString(RunData rundata, Context context) throws Exception {
    String result = "";
    JSONArray json;

    try {

      String featureid = rundata.getParameters().getString("featureid");

      if (featureid != null && !"".equals(featureid)) {
        json =
            JSONArray.fromObject(
                ALAccessControlUtil.getAclLiteBeansFromFeatureId(rundata, featureid));
      } else {
        json = new JSONArray();
      }
      result = json.toString();
    } catch (Exception e) {
      logger.error("PortletFeatureLiteJSONScreen.getJSONString", e);
    }

    return result;
  }
}
コード例 #4
0
ファイル: UserDetailScreen.java プロジェクト: kayokomiko/aipo
/** ユーザーアカウントの詳細画面を処理するクラスです。 <br> */
public class UserDetailScreen extends ALVelocityScreen {

  /** logger */
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(UserDetailScreen.class.getName());

  /**
   * @param rundata
   * @param context
   * @throws Exception
   */
  @Override
  protected void doOutput(RunData rundata, Context context) throws Exception {
    try {
      UserSelectData detailData = new UserSelectData();
      detailData.initField();
      detailData.doViewDetail(this, rundata, context);

      String entityid = ALEipUtils.getTemp(rundata, context, ALEipConstants.ENTITY_ID);
      context.put(ALEipConstants.ENTITY_ID, entityid);

      String layout_template = "portlets/html/ajax-userlist-detail.vm";
      setTemplate(rundata, context, layout_template);
    } catch (Exception ex) {
      logger.error("[AccountUserDetailScreen] Exception.", ex);
      ALEipUtils.redirectDBError(rundata);
    }
  }

  /** @return */
  @Override
  protected String getPortletName() {
    return UserListUtils.USERLIST_PORTLET_NAME;
  }
}
コード例 #5
0
/** Webメールのフォームデータを管理するためのクラスです。 <br> */
public class WebMailFormScreen extends ALVelocityScreen {

  /** logger */
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(WebMailFormScreen.class.getName());

  /**
   * @param rundata
   * @param context
   * @throws Exception
   */
  @Override
  protected void doOutput(RunData rundata, Context context) throws Exception {
    try {
      WebMailFormData formData = new WebMailFormData();
      formData.initField();
      formData.doViewForm(this, rundata, context);
      setTemplate(rundata, context, "portlets/html/ja/ajax-webmail-form.vm");
    } catch (Exception ex) {
      logger.error("[WebMailFormScreen] Exception.", ex);
      ALEipUtils.redirectDBError(rundata);
    }
  }

  /** @return */
  @Override
  protected String getPortletName() {
    return WebMailUtils.WEBMAIL_PORTLET_NAME;
  }
}
コード例 #6
0
ファイル: MyPagesListBox.java プロジェクト: kayokomiko/aipo
/**
 * Returns list box control populated with pmsl pages for current user for current media type.
 *
 * @author <a href="*****@*****.**">Mark Orciuch</a>
 * @version $Id: MyPagesListBox.java,v 1.5 2004/02/23 03:01:20 jford Exp $
 */
public class MyPagesListBox extends VelocityParameterPresentationStyle {

  /** Static initialization of the logger for this class */
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(MyPagesListBox.class.getName());

  /**
   * Put custom objects in the velocity context
   *
   * @param data
   * @param name
   * @param value
   * @param parms
   * @param context
   */
  @SuppressWarnings({"rawtypes", "deprecation", "unchecked"})
  @Override
  public void buildContext(RunData rundata, String name, String value, Map parms, Context context) {
    Map entries = null;

    try {
      entries = (Map) rundata.getUser().getTemp(PsmlManagerAction.CACHED_PSML);
      if (entries == null) {
        // Initialize the query locator
        QueryLocator ql = new QueryLocator(QueryLocator.QUERY_USER);

        JetspeedRunData jdata = (JetspeedRunData) rundata;
        ql.setUser(jdata.getJetspeedUser());
        // ql.setMediaType(jdata.getCapability().getPreferredMediaType());
        entries = new Hashtable();
        Iterator i = Profiler.query(ql);
        while (i.hasNext()) {
          Profile profile = (Profile) i.next();

          String mediaType = profile.getMediaType();
          if (mediaType != null
              && mediaType.equals(jdata.getCapability().getPreferredMediaType())) {
            if (PortletUtils.canAccessProfile(rundata, profile)) {
              if (logger.isDebugEnabled()) {
                logger.debug("MyPagesListBox: refreshing user profile list: " + profile.getPath());
              }
              String title = profile.getName();
              if (profile.getRootSet() != null && profile.getRootSet().getTitle() != null) {
                title = profile.getRootSet().getTitle();
              }
              entries.put(profile, title);
            }
          }
        }

        rundata.getUser().setTemp(PsmlManagerAction.CACHED_PSML, entries);
      }

      context.put("pages", entries);
    } catch (Exception e) {
      logger.error("MyPagesListBox.buildContext", e);
    }
  }
}
コード例 #7
0
ファイル: ALPreExecuteHandler.java プロジェクト: reskohz/aipo
public abstract class ALPreExecuteHandler {

  @SuppressWarnings("unused")
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(ALPreExecuteHandler.class.getName());

  public abstract void migratePsml(RunData rundata, Context context);
}
コード例 #8
0
public class ALDefaultStorageFactoryService extends ALStorageFactoryService {

  @SuppressWarnings("unused")
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(ALStorageFactoryService.class.getName());

  /** @return */
  @Override
  public ALStorageHandler getStorageHandler() {
    return ALDefaultStorageHandler.getInstance();
  }
}
コード例 #9
0
/** メールを操作するクラスを生成するファクトリクラスです。 <br> */
public abstract class ALMailFactoryService extends TurbineBaseService {

  /** logger */
  @SuppressWarnings("unused")
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(ALMailFactoryService.class.getName());

  /** The key under which this service is stored in TurbineServices. */
  public static final String SERVICE_NAME = "ALMailFactoryService";

  /** The JetspeedRunData Service. */
  protected JetspeedRunDataService runDataService = null;

  public static ALMailFactoryService getInstance() {
    return (ALMailFactoryService)
        TurbineServices.getInstance().getService(ALMailFactoryService.SERVICE_NAME);
  }

  public abstract ALMailHandler getMailHandler();

  protected JetspeedRunData getRunData() {
    JetspeedRunData rundata = null;
    if (this.runDataService != null) {
      rundata = this.runDataService.getCurrentRunData();
    }
    return rundata;
  }

  // /////////////////////////////////////////////////////////////////////////
  // Service Init
  // /////////////////////////////////////////////////////////////////////////

  /**
   * This is the early initialization method called by the Turbine <code>Service</code> framework
   *
   * @param conf The <code>ServletConfig</code>
   * @exception throws a <code>InitializationException</code> if the service fails to initialize
   */
  @Override
  public synchronized void init(ServletConfig conf) throws InitializationException {
    if (getInit()) {
      return;
    }

    super.init(conf);

    this.runDataService =
        (JetspeedRunDataService)
            TurbineServices.getInstance().getService(RunDataService.SERVICE_NAME);

    setInit(true);
  }
}
コード例 #10
0
public class ALDefaultPreExecuteFactoryService extends ALPreExecuteFactoryService {

  @SuppressWarnings("unused")
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(ALDefaultPreExecuteFactoryService.class.getName());

  ALPreExecuteHandler handler = new ALDefaultPreExecuteHanlder();

  /** @return */
  @Override
  public ALPreExecuteHandler getPreExecuteHandler() {
    return handler;
  }
}
コード例 #11
0
/** 複数の伝言メモを既読にするクラスです */
public class NoteMultiStateUpdate extends ALAbstractCheckList {

  /** logger */
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(NoteMultiStateUpdate.class.getName());

  /**
   * @param rundata
   * @param context
   * @param values
   * @param msgList
   * @return
   * @throws ALPageNotFoundException
   * @throws ALDBErrorException
   */
  @Override
  protected boolean action(
      RunData rundata, Context context, List<String> values, List<String> msgList)
      throws ALPageNotFoundException, ALDBErrorException {
    try {

      Expression exp1 =
          ExpressionFactory.matchExp(
              EipTNoteMap.USER_ID_PROPERTY, Integer.valueOf(ALEipUtils.getUserId(rundata)));
      Expression exp2 = ExpressionFactory.inDbExp(EipTNote.NOTE_ID_PK_COLUMN, values);

      List<EipTNoteMap> list =
          Database.query(EipTNoteMap.class, exp1).andQualifier(exp2).fetchList();

      if (list == null || list.size() <= 0) {
        return false;
      }

      for (EipTNoteMap notemap : list) {
        notemap.setNoteStat(NoteUtils.NOTE_STAT_READ);
      }

      Database.commit();
    } catch (Exception ex) {
      Database.rollback();
      logger.error("note", ex);
      return false;
    }
    return true;
  }
}
コード例 #12
0
ファイル: ActivityListScreen.java プロジェクト: ntamvl/aipo
public class ActivityListScreen extends ALVelocityScreen {

  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(ActivityListScreen.class.getName());

  /**
   * @param rundata
   * @param context
   * @throws Exception
   */
  @Override
  protected void doOutput(RunData rundata, Context context) throws Exception {

    try {
      String portletId = ActivityUtils.getGlobalPortletId(rundata);
      context.put("portletId", ActivityUtils.getGlobalPortletId(rundata));
      Portlet portlet = ALEipUtils.getPortlet(rundata, portletId);
      String desktopNotificationParam =
          portlet.getPortletConfig().getInitParameter("desktopNotification");
      context.put("desktopNotification", "T".equals(desktopNotificationParam));
      String support = rundata.getParameters().getString("s");
      context.put("notifySupport", "1".equals(support));
      String permission = rundata.getParameters().getString("p");
      context.put("notifyPermission", "0".equals(permission) || "granted".equals(permission));

      ActivitySelectData listData = new ActivitySelectData();
      listData.initField();
      listData.setRowsNum(5);
      listData.doViewList(this, rundata, context);
      String layout_template = "portlets/html/ja/ajax-activity-list.vm";
      setTemplate(rundata, context, layout_template);
    } catch (Exception ex) {
      logger.error("ActivityListScreen.doOutput", ex);
      ALEipUtils.redirectDBError(rundata);
    }
  }

  /** @return */
  @Override
  protected String getPortletName() {
    return ActivityUtils.ACTIVITY_PORTLET_NAME;
  }
}
コード例 #13
0
ファイル: WikiViewScreen.java プロジェクト: ntamvl/aipo
/** Wikiの閲覧画面を処理するクラスです。 <br> */
public class WikiViewScreen extends WikiScreen {

  /** logger */
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(WikiViewScreen.class.getName());

  /**
   * @param rundata
   * @param context
   * @throws Exception
   */
  @Override
  protected void doOutput(RunData rundata, Context context) throws Exception {
    try {
      WikiSelectData listData = new WikiSelectData();
      listData.initField();
      listData.loadTopWikiList(rundata, context);
      listData.doViewDetailOne(this, rundata, context);

      String layout_template = "portlets/html/ja/ajax-wiki-view.vm";
      setTemplate(rundata, context, layout_template);

    } catch (Exception ex) {
      logger.error("[WikiViewScreen] Exception.", ex);
      ALEipUtils.redirectDBError(rundata);
    }
  }

  /**
   * ポートレット名取得
   *
   * @return ポートレット名
   */
  @Override
  protected String getPortletName() {
    return WikiUtils.WIKI_PORTLET_NAME;
  }
}
コード例 #14
0
/** 管理者用メールアカウントの詳細画面を処理するクラスです。 <br> */
public class SystemWebMailAdminFormScreen extends ALVelocityScreen {

  /** logger */
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(SystemWebMailAdminFormScreen.class.getName());

  /**
   * @param rundata
   * @param context
   * @throws Exception
   */
  @Override
  protected void doOutput(RunData rundata, Context context) throws Exception {
    try {
      SystemWebMailAccountFormData formData = new SystemWebMailAccountFormData();
      formData.initField();
      formData.doViewForm(this, rundata, context);
      if (formData.getAccountName().getValue() == null) {
        context.put("mode_form", "new_form");
      } else {
        context.put("mode_form", "edit_form");
      }

      setTemplate(rundata, context, "portlets/html/ajax-system-webmail-account-form-admin.vm");

    } catch (Exception ex) {
      logger.error("[WebMailAdminFormScreen] Exception.", ex);
      ALEipUtils.redirectDBError(rundata);
    }
  }

  /** @return */
  @Override
  protected String getPortletName() {
    return SystemWebMailUtils.WEBMAIL_ADMIN_PORTLET_NAME;
  }
}
コード例 #15
0
ファイル: ReportFormScreen.java プロジェクト: reskohz/aipo
/** 報告書を処理するクラスです。 <br> */
public class ReportFormScreen extends ALVelocityScreen {

  /** logger */
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(ReportFormScreen.class.getName());

  /**
   * @param rundata
   * @param context
   * @throws Exception
   */
  @Override
  protected void doOutput(RunData rundata, Context context) throws Exception {

    try {
      doReport_form(rundata, context);
    } catch (Exception ex) {
      logger.error("[ReportFormScreen] Exception.", ex);
      ALEipUtils.redirectDBError(rundata);
    }
  }

  protected void doReport_form(RunData rundata, Context context) {
    ReportFormData formData = new ReportFormData();
    formData.initField();
    formData.doViewForm(this, rundata, context);

    String layout_template = "portlets/html/ajax-report-form.vm";
    setTemplate(rundata, context, layout_template);
  }

  /** @return */
  @Override
  protected String getPortletName() {
    return ReportUtils.REPORT_PORTLET_NAME;
  }
}
コード例 #16
0
/** 個人設定・ユーザー情報をJSONデータとして出力するクラスです。 <br> */
public class AccountPersonFormJSONScreen extends ALJSONScreen {

  /** logger */
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(AccountPersonFormJSONScreen.class.getName());

  @Override
  protected String getJSONString(RunData rundata, Context context) throws Exception {
    String result = new JSONArray().toString();
    String mode = this.getMode();
    try {

      if (ALEipConstants.MODE_UPDATE_PASSWD.equals(mode)) {
        AccountPasswdFormData formData = new AccountPasswdFormData();
        formData.initField();
        if (formData.doUpdate(this, rundata, context)) {
        } else {
          JSONArray json = JSONArray.fromObject(context.get(ALEipConstants.ERROR_MESSAGE_LIST));
          result = json.toString();
        }
      } else {
        AccountEditFormData formData = new AccountEditFormData();
        formData.initField();
        if (formData.doUpdate(this, rundata, context)) {
        } else {
          JSONArray json = JSONArray.fromObject(context.get(ALEipConstants.ERROR_MESSAGE_LIST));
          result = json.toString();
        }
      }
    } catch (Exception e) {
      logger.error("AccountPersonFormJSONScreen.getJSONString", e);
    }

    return result;
  }
}
コード例 #17
0
ファイル: BaseJetspeedUser.java プロジェクト: reskohz/aipo
/**
 * The default Jetspeed implementation of User interface.
 *
 * <p>This basic implementation contains the functionality that is expected to be common among all
 * User implementations. You are welcome to extend this class if you wish to have custom
 * functionality in your user objects (like accessor methods for custom attributes).
 *
 * @author <a href="mailto:[email protected]">David Sean Taylor</a>
 * @author <a href="mailto:[email protected]">Mark Orciuch</a>
 * @version $Id: BaseJetspeedUser.java,v 1.11 2004/02/23 03:14:12 jford Exp $
 */
public class BaseJetspeedUser /* extends SecurityObject */ implements JetspeedUser {
  /** The date on which the user account was created. */
  private Date createDate = null;

  /** The date on which the user last accessed the application. */
  private Date lastAccessDate = null;

  /** This is data that will survive a servlet engine restart. */
  private Hashtable permStorage = null;

  /** This is data that will not survive a servlet engine restart. */
  private Hashtable tempStorage = null;

  protected String name = "";

  protected boolean isNew = true;

  /** Static initialization of the logger for this class */
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(BaseJetspeedUser.class.getName());

  /** Constructor. Create a new User and set the createDate. */
  public BaseJetspeedUser() {
    createDate = new Date();
    tempStorage = new Hashtable(10);
    permStorage = new Hashtable(10);
    setHasLoggedIn(Boolean.FALSE);
    setDisabled("F");
    isNew = true;
  }

  /**
   * Returns the primary principle for this User, the user id.
   *
   * @return the user id.
   */
  public String getUserId() {
    String tmp = null;
    try {
      tmp = (String) getPerm(JetspeedUser.USER_ID);
      if (tmp != null && tmp.length() == 0) {
        tmp = null;
      }
    } catch (Exception e) {
      logger.error("getUserId(): " + e.getMessage(), e);
    }
    return tmp;
  }

  public void setUserId(String id) {
    if (getUserId() == null) {
      setPerm(JetspeedUser.USER_ID, id);
    }
  }

  /**
   * Gets the access counter for a user during a session.
   *
   * @return The access counter for the user for the session.
   */
  public int getAccessCounterForSession() {
    int accessCounter = 0;
    try {
      Integer temp = (Integer) getTemp(User.SESSION_ACCESS_COUNTER);
      if (temp != null) {
        accessCounter = temp.intValue();
      }
    } catch (Exception e) {
      logger.debug("getAccessCounterForSession(): " + e.getMessage(), e);
    }

    return accessCounter;
  }

  /**
   * Gets the access counter for a user from perm storage.
   *
   * @return The access counter for the user.
   */
  public int getAccessCounter() {
    int accessCounter = 0;
    try {
      Integer temp = (Integer) getPerm(User.ACCESS_COUNTER);
      if (temp != null) {
        accessCounter = temp.intValue();
      }
    } catch (Exception e) {
      logger.debug("getAccessCounter(): " + e.getMessage(), e);
    }
    return accessCounter;
  }

  /**
   * Gets the create date for this User. This is the time at which the user object was created.
   *
   * @return A Java Date with the date of creation for the user.
   */
  public java.util.Date getCreateDate() {
    return createDate;
  }

  /**
   * Gets the last access date for this User. This is the last time that the user object was
   * referenced.
   *
   * @return A Java Date with the last access date for the user.
   */
  public java.util.Date getLastAccessDate() {
    if (lastAccessDate == null) {
      setLastAccessDate();
    }
    return lastAccessDate;
  }

  /**
   * Get last login date/time for this user.
   *
   * @return A Java Date with the last login date for the user.
   */
  public java.util.Date getLastLogin() {
    return (java.util.Date) getPerm(User.LAST_LOGIN);
  }

  /**
   * Get password for this user.
   *
   * @return A String with the password for the user.
   */
  public String getPassword() {
    return (String) getPerm(User.PASSWORD);
  }

  /**
   * Get an object from permanent storage.
   *
   * @param name The object's name.
   * @return An Object with the given name.
   */
  public Object getPerm(String name) {
    return permStorage.get(name);
  }

  /**
   * Get an object from permanent storage; return default if value is null.
   *
   * @param name The object's name.
   * @param def A default value to return.
   * @return An Object with the given name.
   */
  public Object getPerm(String name, Object def) {
    try {
      Object val = permStorage.get(name);
      return (val == null ? def : val);
    } catch (Exception e) {
      logger.error("getPerm(" + name + "): " + e.getMessage(), e);
      return def;
    }
  }

  /**
   * This should only be used in the case where we want to save the data to the database.
   *
   * @return A Hashtable.
   */
  public Hashtable getPermStorage() {
    if (this.permStorage == null) {
      this.permStorage = new Hashtable();
    }
    return this.permStorage;
  }

  /**
   * Get an object from temporary storage.
   *
   * @param name The object's name.
   * @return An Object with the given name.
   */
  public Object getTemp(String name) {
    return tempStorage.get(name);
  }

  /**
   * Get an object from temporary storage; return default if value is null.
   *
   * @param name The object's name.
   * @param def A default value to return.
   * @return An Object with the given name.
   */
  public Object getTemp(String name, Object def) {
    Object val;
    try {
      val = tempStorage.get(name);
      if (val == null) {
        val = def;
      }
    } catch (Exception e) {
      logger.error("getTemp(" + name + "): " + e.getMessage(), e);
      val = def;
    }
    return val;
  }

  /**
   * Returns the username for this user. If this is defined, then the user is considered logged in.
   *
   * @return A String with the username.
   */
  public String getUserName() {
    String tmp = null;
    try {
      tmp = (String) getPerm(User.USERNAME);
      if (tmp.length() == 0) {
        tmp = null;
      }
    } catch (Exception e) {
      logger.error("getUserName(): " + e.getMessage(), e);
    }
    return tmp;
  }

  /**
   * Returns the first name for this user. If this is defined, then the user is considered logged
   * in.
   *
   * @return A String with the user's first name.
   */
  public String getFirstName() {
    String tmp = null;
    try {
      tmp = (String) getPerm(User.FIRST_NAME);
      if (tmp.length() == 0) {
        tmp = null;
      }
    } catch (Exception e) {
      logger.error("getFirstName(): " + e.getMessage(), e);
    }
    return tmp;
  }

  /**
   * Returns the last name for this user. If this is defined, then the user is considered logged in.
   *
   * @return A String with the user's last name.
   */
  public String getLastName() {
    String tmp = null;
    try {
      tmp = (String) getPerm(User.LAST_NAME);
      if (tmp.length() == 0) tmp = null;
    } catch (Exception e) {
      logger.error("getLastName(): " + e.getMessage(), e);
    }
    return tmp;
  }

  /**
   * The user is considered logged in if they have not timed out.
   *
   * @return Whether the user has logged in.
   */
  public boolean hasLoggedIn() {
    Boolean loggedIn = getHasLoggedIn();
    return (loggedIn != null && loggedIn.booleanValue());
  }

  /**
   * Returns the email address for this user.
   *
   * @return A String with the user's email address.
   */
  public String getEmail() {
    return (String) getPerm(User.EMAIL);
  }

  /** Increments the permanent hit counter for the user. */
  public void incrementAccessCounter() {
    setAccessCounter(getAccessCounter() + 1);
  }

  /** Increments the session hit counter for the user. */
  public void incrementAccessCounterForSession() {
    setAccessCounterForSession(getAccessCounterForSession() + 1);
  }

  /**
   * Remove an object from temporary storage and return the object.
   *
   * @param name The name of the object to remove.
   * @return An Object.
   */
  public Object removeTemp(String name) {
    return tempStorage.remove(name);
  }

  /**
   * Sets the access counter for a user, saved in perm storage.
   *
   * @param cnt The new count.
   */
  public void setAccessCounter(int cnt) {
    setPerm(User.ACCESS_COUNTER, new Integer(cnt));
  }

  /**
   * Sets the session access counter for a user, saved in temp storage.
   *
   * @param cnt The new count.
   */
  public void setAccessCounterForSession(int cnt) {
    setTemp(User.SESSION_ACCESS_COUNTER, new Integer(cnt));
  }

  /**
   * Sets the last access date for this User. This is the last time that the user object was
   * referenced.
   */
  public void setLastAccessDate() {
    lastAccessDate = new java.util.Date();
  }

  /**
   * Sets the create date for this User. This is the time at which the user object was created.
   *
   * @param date The create date.
   */
  public void setCreateDate(java.util.Date date) {
    createDate = date;
  }

  /**
   * Set last login date/time.
   *
   * @param date The last login date.
   */
  public void setLastLogin(java.util.Date date) {
    setPerm(User.LAST_LOGIN, date);
  }

  /**
   * Set password.
   *
   * @param password The new password.
   */
  public void setPassword(String password) {
    setPerm(User.PASSWORD, password);
  }

  /**
   * Put an object into permanent storage. If the value is null, it will convert that to a ""
   * because the underlying storage mechanism within TurbineUser is currently a Hashtable and null
   * is not a valid value.
   *
   * @param name The object's name.
   * @param value The object.
   */
  public void setPerm(String name, Object value) {
    ObjectUtils.safeAddToHashtable(getPermStorage(), name, value);
  }

  /**
   * This should only be used in the case where we want to save the data to the database.
   *
   * @param stuff A Hashtable.
   */
  public void setPermStorage(Hashtable stuff) {
    this.permStorage = stuff;
  }

  /**
   * This should only be used in the case where we want to save the data to the database.
   *
   * @return A Hashtable.
   */
  public Hashtable getTempStorage() {
    if (this.tempStorage == null) {
      this.tempStorage = new Hashtable();
    }
    return this.tempStorage;
  }

  /**
   * This should only be used in the case where we want to save the data to the database.
   *
   * @param storage A Hashtable.
   */
  public void setTempStorage(Hashtable storage) {
    this.tempStorage = storage;
  }

  /**
   * This gets whether or not someone has logged in. hasLoggedIn() returns this value as a boolean.
   * This is private because you should use hasLoggedIn() instead.
   *
   * @return True if someone has logged in.
   */
  private Boolean getHasLoggedIn() {
    return (Boolean) getTemp(User.HAS_LOGGED_IN);
  }

  /**
   * This sets whether or not someone has logged in. hasLoggedIn() returns this value.
   *
   * @param value Whether someone has logged in or not.
   */
  public void setHasLoggedIn(Boolean value) {
    setTemp(User.HAS_LOGGED_IN, value);
  }

  /**
   * Put an object into temporary storage. If the value is null, it will convert that to a ""
   * because the underlying storage mechanism within TurbineUser is currently a Hashtable and null
   * is not a valid value.
   *
   * @param name The object's name.
   * @param value The object.
   */
  public void setTemp(String name, Object value) {
    ObjectUtils.safeAddToHashtable(tempStorage, name, value);
  }

  /**
   * Sets the username for this user.
   *
   * @param username The user's username.
   */
  public void setUserName(String username) {
    setPerm(User.USERNAME, username);
  }

  /**
   * Sets the first name for this user.
   *
   * @param firstName User's first name.
   */
  public void setFirstName(String firstName) {
    setPerm(User.FIRST_NAME, firstName);
  }

  /**
   * Sets the last name for this user.
   *
   * @param lastName User's last name.
   */
  public void setLastName(String lastName) {
    setPerm(User.LAST_NAME, lastName);
  }

  /**
   * Sets the email address.
   *
   * @param address The email address.
   */
  public void setEmail(String address) {
    setPerm(User.EMAIL, address);
  }

  /**
   * This method reports whether or not the user has been confirmed in the system by checking the
   * User.CONFIRM_VALUE column in the users record to see if it is equal to User.CONFIRM_DATA.
   *
   * @return True if the user has been confirmed.
   */
  public boolean isConfirmed() {
    String value = getConfirmed();
    return (value != null && value.equals(User.CONFIRM_DATA));
  }

  /**
   * Sets the confirmation value. The value should be either a random string or User.CONFIRM_DATA
   *
   * @param value The confirmation key value.
   */
  public void setConfirmed(String value) {
    String val = "";
    if (value != null) {
      val = value;
    }
    setPerm(User.CONFIRM_VALUE, val);
  }

  /**
   * Gets the confirmation value.
   *
   * @return status The confirmation value for this User
   */
  public String getConfirmed() {
    return (String) getPerm(User.CONFIRM_VALUE);
  }

  /**
   * Updates the last login date in the database.
   *
   * @exception Exception, a generic exception.
   */
  public void updateLastLogin() throws Exception {
    setPerm(User.LAST_LOGIN, new java.util.Date());
  }

  /**
   * Implement this method if you wish to be notified when the User has been Bound to the session.
   *
   * @param hsbe The HttpSessionBindingEvent.
   */
  public void valueBound(HttpSessionBindingEvent hsbe) {
    // Currently we have no need for this method.
  }

  /**
   * Implement this method if you wish to be notified when the User has been Unbound from the
   * session.
   *
   * @param hsbe The HttpSessionBindingEvent.
   */
  public void valueUnbound(HttpSessionBindingEvent hsbe) {

    try {
      java.util.Date now = new java.util.Date();
      // System.out.println("*********** value unbound ********************: " +
      // now.toString());
      if (this.hasLoggedIn()) {
        if (JetspeedResources.getBoolean("automatic.logout.save", false)) {
          JetspeedUserManagement.saveUser(this);
        }
        JetspeedAuthentication.logout();
      }

    } catch (Exception e) {
      logger.error("TurbineUser.valueUnbound(): " + e.getMessage(), e);

      // To prevent messages being lost in case the logging system
      // goes away before sessions get unbound on servlet container
      // shutdown, print the stcktrace to the container's console.
      ByteArrayOutputStream ostr = new ByteArrayOutputStream();
      e.printStackTrace(new PrintWriter(ostr, true));
      String stackTrace = ostr.toString();
      System.out.println(stackTrace);
    }
  }

  /** Saves this object to the data store. */
  public void save() throws Exception {
    if (this.isNew()) {
      JetspeedUserManagement.addUser(this);
    } else {
      JetspeedUserManagement.saveUser(this);
    }
  }

  /**
   * Returns the disabled status for the user
   *
   * @return True when the account is disabled
   */
  public String getDisabled() {
    String disabled = null;
    try {
      String tmp = (String) getPerm(JetspeedUser.DISABLED);
      if (tmp != null && tmp.length() > 0) {
        disabled = tmp;
      }
    } catch (Exception e) {
      logger.error("getDisabled(): " + e.getMessage(), e);
    }
    return disabled;
  }

  public void setDisabled(String disabled) {
    setPerm(JetspeedUser.DISABLED, disabled);
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public boolean isNew() {
    return isNew;
  }

  protected void setNew(boolean isNew) {
    this.isNew = isNew;
  }

  /** @see org.apache.jetspeed.om.security.JetspeedUser#getPasswordChanged */
  public Date getPasswordChanged() {
    return (Date) getPerm(JetspeedUser.PASSWORD_CHANGED);
  }

  /** @see org.apache.jetspeed.om.security.JetspeedUser#setPasswordChanged */
  public void setPasswordChanged(Date value) {
    setPerm(JetspeedUser.PASSWORD_CHANGED, value);
  }
}
コード例 #18
0
/** アドレスブック・会社情報のファイル出力を取り扱うクラスです */
public class AddressBookCompanyXlsExportScreen extends ALXlsScreen {

  /** logger */
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(AddressBookXlsExportScreen.class.getName());

  /** アドレスブックファイルを一時保管するディレクトリの指定 */
  public static final String FOLDER_TMP_FOR_ADDRESSBOOK_FILES =
      JetspeedResources.getString("aipo.tmp.addressbook.directory", "");

  public static final String FILE_NAME = "addressbookcompany.xls";

  /** ログインユーザーID */
  private String userid;

  /** アクセス権限の機能名 */
  private String aclPortletFeature = null;

  /**
   * 初期化処理を行います。
   *
   * @param action
   * @param rundata
   * @param context
   */
  @Override
  public void init(RunData rundata, Context context)
      throws ALPageNotFoundException, ALDBErrorException {

    String target_user_id = rundata.getParameters().getString("target_user_id" /*
                                                         * AddressBookUtils.
                                                         * TARGET_USER_ID
                                                         */);
    userid = Integer.toString(ALEipUtils.getUserId(rundata));

    // アクセス権
    if (
    // target_user_id == null || "".equals(target_user_id)
    // ||
    userid.equals(target_user_id)) {
      aclPortletFeature = ALAccessControlConstants.POERTLET_FEATURE_ADDRESSBOOK_ADDRESS_OUTSIDE;
    }
    // else {
    // aclPortletFeature =
    // ALAccessControlConstants.POERTLET_FEATURE_TIMECARD_TIMECARD_OTHER;
    // }

    super.init(rundata, context);
  }

  @Override
  protected boolean createHSSFWorkbook(RunData rundata, Context context, HSSFWorkbook wb) {
    try {
      setupAddressBookSheet(rundata, context, wb);
    } catch (Exception e) {
      logger.error("AddressBookCompanyXlsExportScreen.createHSSFWorkbook", e);
      return false;
    }
    return true;
  }

  private void setupAddressBookSheet(RunData rundata, Context context, HSSFWorkbook wb)
      throws Exception {

    String sheet_name = "アドレスブック(会社情報)";
    // ヘッダ部作成
    String[] headers = {"会社名", "会社名(フリガナ)", "部署名", "郵便番号", "住所", "電話番号", "FAX", "URL"};
    // 0:日本語,1:英数字
    short[] cell_enc_types = {
      HSSFCell.ENCODING_UTF_16,
      HSSFCell.ENCODING_UTF_16,
      HSSFCell.ENCODING_UTF_16,
      HSSFCell.ENCODING_UTF_16,
      HSSFCell.ENCODING_UTF_16,
      HSSFCell.ENCODING_UTF_16,
      HSSFCell.ENCODING_UTF_16,
      HSSFCell.ENCODING_UTF_16
    };
    HSSFSheet sheet = createHSSFSheet(wb, sheet_name, headers, cell_enc_types);

    int rowcount = 0;

    // スタイルの設定
    HSSFCellStyle style_col = wb.createCellStyle();
    style_col.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
    style_col.setAlignment(HSSFCellStyle.ALIGN_JUSTIFY);

    AddressBookCompanySelectData listData = new AddressBookCompanySelectData();

    listData.initField();
    listData.setRowsNum(1000);
    listData.doSelectList(this, rundata, context);
    int page_num = listData.getPagesNum();
    int current_page = 1;
    while (true) {
      int listsize = listData.getList().size();
      AddressBookCompanyResultData rd;
      for (int j = 0; j < listsize; j++) {
        rd = (AddressBookCompanyResultData) listData.getList().get(j);
        String[] rows = {
          rd.getCompanyName().getValue(),
          rd.getCompanyNameKana().getValue(),
          rd.getPostName().getValue(),
          rd.getZipcode().getValue(),
          rd.getAddress().getValue(),
          rd.getTelephone().getValue(),
          rd.getFaxNumber().getValue(),
          rd.getUrl().getValue()
        };

        rowcount = rowcount + 1;
        addRow(sheet.createRow(rowcount), cell_enc_types, rows);
      }

      current_page++;
      if (current_page > page_num) {
        break;
      }
      listData.setCurrentPage(current_page);
      listData.doSelectList(this, rundata, context);
    }

    int uid = ALEipUtils.getUserId(rundata);
    ALEventlogFactoryService.getInstance()
        .getEventlogHandler()
        .logXlsScreen(
            uid,
            "アドレスブック(会社情報)出力",
            163 /* ALEventlogConstants.PORTLET_TYPE_ADDRESSBOOK_XLS_SCREEN */);
  }

  @Override
  protected String getFileName() {
    return FILE_NAME;
  }

  /**
   * アクセス権限チェック用メソッド。 アクセス権限の機能名を返します。
   *
   * @return
   */
  @Override
  public String getAclPortletFeature() {
    return aclPortletFeature;
  }
}
コード例 #19
0
/** ユーザーアカウントのパスワードのフォームデータを管理するためのクラスです。 <br> */
public class AccountPasswdFormData extends ALAbstractFormData {

  /** logger */
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(AccountPasswdFormData.class.getName());

  /** 新しいパスワード */
  private ALStringField new_passwd;

  /** 新しいパスワード(確認用) */
  private ALStringField new_passwd_confirm;

  /**
   * 初期化する <br>
   *
   * @param action
   * @param rundata
   * @param context
   */
  @Override
  public void init(ALAction action, RunData rundata, Context context)
      throws ALPageNotFoundException, ALDBErrorException {
    if (ALEipUtils.isMatch(rundata, context)) {
      ALEipUtils.setTemp(
          rundata, context, ALEipConstants.ENTITY_ID, rundata.getUser().getUserName());
    }
  }

  /** */
  @Override
  public void initField() {
    // 新しいパスワード
    new_passwd = new ALStringField();
    new_passwd.setFieldName("新しいパスワード");
    new_passwd.setTrim(true);

    // 新しいパスワード(確認用)
    new_passwd_confirm = new ALStringField();
    new_passwd_confirm.setFieldName("新しいパスワード(確認用)");
    new_passwd_confirm.setTrim(true);
  }

  /** */
  @Override
  protected void setValidator() {
    // 新しいパスワード
    new_passwd.setNotNull(true);
    new_passwd.setCharacterType(ALStringField.TYPE_ALPHABET_NUMBER);
    new_passwd.limitMaxLength(16);

    // 新しいパスワード(確認用)
    new_passwd_confirm.setNotNull(true);
    new_passwd_confirm.setCharacterType(ALStringField.TYPE_ALPHABET_NUMBER);
    new_passwd_confirm.limitMaxLength(16);
  }

  /** */
  @Override
  protected boolean validate(List<String> msgList) {
    new_passwd.validate(msgList);
    new_passwd_confirm.validate(msgList);

    if (!new_passwd.toString().equals(new_passwd_confirm.toString())) {
      msgList.add(ALLocalizationUtils.getl10n("ACCOUNT_ALERT_NEWPW"));
    }
    return (msgList.size() == 0);
  }

  /**
   * @param rundata
   * @param context
   * @param msgList
   * @return
   */
  @Override
  protected boolean loadFormData(RunData rundata, Context context, List<String> msgList) {
    return false;
  }

  /**
   * @param rundata
   * @param context
   * @param msgList
   * @return
   */
  @Override
  protected boolean insertFormData(RunData rundata, Context context, List<String> msgList) {
    return false;
  }

  /**
   * @param rundata
   * @param context
   * @param msgList
   * @return
   */
  @Override
  protected boolean updateFormData(RunData rundata, Context context, List<String> msgList) {
    boolean res = true;
    try {

      ALBaseUser user = AccountUtils.getBaseUser(rundata, context);
      if (user == null) {
        return false;
      }

      // WebAPIのDBへ接続できるか確認
      if (!ALDataSyncFactoryService.getInstance().getDataSyncHandler().checkConnect()) {
        msgList.add(ALLocalizationUtils.getl10n("ACCOUNT_ALERT_CONNECT_DB_FAILED"));
        return false;
      }

      // 新しいパスワードをセットする
      JetspeedSecurity.forcePassword(user, new_passwd.toString());

      // ユーザを更新する
      JetspeedSecurity.saveUser(user);

      // WebAPIとのDB同期
      if (!ALDataSyncFactoryService.getInstance().getDataSyncHandler().updateUser(user)) {
        return false;
      }

      ALBaseUser currentUser = (ALBaseUser) rundata.getUser();
      if (currentUser.getUserName().equals(user.getUserName())) {
        currentUser.setPassword(user.getPassword());
      }

      // イベントログに保存
      ALEventlogFactoryService.getInstance()
          .getEventlogHandler()
          .log(Integer.valueOf(user.getUserId()), ALEventlogConstants.PORTLET_TYPE_ACCOUNT, null);

    } catch (Exception e) {
      logger.error("AccountPasswdFormData.updateFormData", e);
      res = false;
    }
    return res;
  }

  /**
   * @param rundata
   * @param context
   * @param msgList
   * @return
   */
  @Override
  protected boolean deleteFormData(RunData rundata, Context context, List<String> msgList) {
    return false;
  }

  /** @return */
  public ALStringField getNewPasswd() {
    return new_passwd;
  }

  /** @return */
  public ALStringField getNewPasswdConfirm() {
    return new_passwd_confirm;
  }

  /** @param field */
  public void setNewPasswd(String field) {
    new_passwd.setValue(field);
  }

  /** @param field */
  public void setNewPasswdConfirm(String field) {
    new_passwd_confirm.setValue(field);
  }
}
コード例 #20
0
ファイル: SecurityCacheImpl.java プロジェクト: ntamvl/aipo
/**
 * The Security Cache Service caches roles and permissions (ACLs)
 *
 * @author <a href="mailto:[email protected]">David Sean Taylor</a>
 * @author <a href="mailto:[email protected]">Mark Orciuch</a>
 * @version $Id: SecurityCacheImpl.java,v 1.10 2004/02/23 03:58:11 jford Exp $
 */
public class SecurityCacheImpl extends TurbineBaseService implements SecurityCacheService {
  /** Static initialization of the logger for this class */
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(SecurityCacheImpl.class.getName());

  protected Map acls = new HashMap();
  protected Map perms = new HashMap();

  /*
   * Utility method for accessing the service
   * implementation
   *
   * @return a SecurityCacheService implementation instance
   */
  protected static SecurityCacheService getService() {
    return (SecurityCacheService)
        TurbineServices.getInstance().getService(SecurityCacheService.SERVICE_NAME);
  }

  /*
   * Load the security cache for the given user's roles and permissions.
   *
   * @param JetspeedUser the user to cache all role and permission information for.
   */
  public void load(String username) throws JetspeedSecurityException {
    CachedAcl acl = new CachedAcl(username);
    acl.setRoles(JetspeedSecurity.getRoles(username));
    acls.put(username, acl);
    if (perms.size() == 0) {
      loadRolePermissions();
    }
  }

  public void unload(String username) {
    acls.remove(username);
  }

  public Role getRole(String roleName) {
    return (Role) perms.get(roleName);
  }

  public Role getRole(String username, String roleName) {
    CachedAcl acl = (CachedAcl) acls.get(username);
    if (acl == null) {
      return null;
    }
    return acl.getRole(roleName);
  }

  public Role getRole(String username, String roleName, String groupName) {
    CachedAcl acl = (CachedAcl) acls.get(username);
    if (acl == null) {
      return null;
    }
    return acl.getRole(roleName, groupName);
  }

  public void addRole(Role role) {
    if (!perms.containsKey(role.getName())) {
      perms.put(role.getName(), new HashMap());
    }
  }

  public void addRole(String username, Role role) {
    CachedAcl acl = (CachedAcl) acls.get(username);
    if (null != acl) {
      acl.addRole(role);
    }
    if (!perms.containsKey(role.getName())) {
      perms.put(role.getName(), new HashMap());
    }
  }

  public void addRole(String username, Role role, Group group) {
    CachedAcl acl = (CachedAcl) acls.get(username);
    if (null != acl) {
      acl.addRole(role, group);
    }
    if (!perms.containsKey(role.getName())) {
      perms.put(role.getName(), new HashMap());
    }
  }

  public boolean hasRole(String username, String roleName) {
    return hasRole(username, roleName, GroupManagement.DEFAULT_GROUP_NAME);
  }

  public boolean hasRole(String username, String roleName, String groupName) {
    CachedAcl acl = (CachedAcl) acls.get(username);
    if (null != acl) {
      return acl.hasRole(roleName, groupName);
    }
    return false;
  }

  public void removeRole(String username, String roleName) {
    removeRole(username, roleName, GroupManagement.DEFAULT_GROUP_NAME);
  }

  public void removeRole(String username, String roleName, String groupName) {
    CachedAcl acl = (CachedAcl) acls.get(username);
    if (null != acl) {
      acl.removeRole(roleName, groupName);
    }
    // TODO: Why do this?
    perms.remove(roleName);
  }

  public CachedAcl getAcl(String username) {
    return (CachedAcl) acls.get(username);
  }

  public Iterator getRoles(String username) {
    CachedAcl acl = (CachedAcl) acls.get(username);
    if (null != acl) {
      return acl.getRoles();
    }
    return null;
  }

  public Permission getPermission(String roleName, String permissionName) {
    Map map = (Map) perms.get(roleName);
    if (null != map) {
      return (Permission) map.get(permissionName);
    }
    return null;
  }

  public void addPermission(String roleName, Permission permission) {
    Map map = (Map) perms.get(roleName);
    if (null != map) {
      map.put(permission.getName(), permission);
    }
  }

  public boolean hasPermission(String roleName, String permissionName) {
    Map map = (Map) perms.get(roleName);
    if (null != map) {
      return map.containsKey(permissionName);
    }
    return false;
  }

  public void removePermission(String roleName, String permissionName) {
    Map map = (Map) perms.get(roleName);
    if (null != map) {
      map.remove(permissionName);
    }
  }

  public Iterator getPermissions(String roleName) {
    Map map = (Map) perms.get(roleName);
    if (map != null) {
      return map.values().iterator();
    }
    return null;
  }

  public void removeAllRoles(String rolename) {
    Iterator iterator = acls.values().iterator();
    while (iterator.hasNext()) {
      CachedAcl acl = (CachedAcl) iterator.next();
      acl.removeRole(rolename);
    }
    perms.remove(rolename);
  }

  public void removeAllPermissions(String permissionName) {
    Iterator iterator = perms.values().iterator();
    while (iterator.hasNext()) {
      Map map = (Map) iterator.next();
      map.remove(permissionName);
    }
  }

  public void loadRolePermissions() {
    try {
      Iterator roles = JetspeedSecurity.getRoles();
      while (roles.hasNext()) {
        Role role = (Role) roles.next();
        Map map = new HashMap();
        Iterator prms = JetspeedSecurity.getPermissions(role.getName());
        while (prms.hasNext()) {
          Permission perm = (Permission) prms.next();
          map.put(perm.getName(), perm);
        }
        perms.put(role.getName(), map);
      }
    } catch (JetspeedSecurityException e) {
      logger.error("Exception", e);
    }
  }
  ///////////////////////////////////////////////////////////////////////////
  // Service Init
  ///////////////////////////////////////////////////////////////////////////

  /**
   * This is the early initialization method called by the Turbine <code>Service</code> framework
   *
   * @param conf The <code>ServletConfig</code>
   * @exception throws a <code>InitializationException</code> if the service fails to initialize
   */
  public synchronized void init(ServletConfig conf) throws InitializationException {
    if (getInit()) return;

    super.init(conf);

    setInit(true);
  }
}
コード例 #21
0
/** 掲示板カテゴリのフォームデータを管理するクラスです。 <br> */
public class MsgboardCategoryFormData extends ALAbstractFormData {

  /** logger */
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(MsgboardCategoryFormData.class.getName());

  /** カテゴリ名 */
  private ALStringField category_name;

  /** メモ */
  private ALStringField note;

  /** 閲覧/返信フラグ */
  private ALNumberField access_flag;

  /** <code>login_user</code> ログインユーザー */
  private ALEipUser login_user;

  /** <code>is_member</code> スケジュールを共有するかどうか */
  private boolean is_member;

  /** <code>memberList</code> メンバーリスト */
  private List<ALEipUser> memberList;

  /** <code>groups</code> グループ */
  private List<ALEipGroup> groups;

  /** 他人のカテゴリ編集権限 */
  private boolean authority_edit;

  /** 他人のカテゴリ削除権限 */
  private boolean authority_delete;

  /**
   * @param action
   * @param rundata
   * @param context
   * @throws ALPageNotFoundException
   * @throws ALDBErrorException
   */
  @Override
  public void init(ALAction action, RunData rundata, Context context)
      throws ALPageNotFoundException, ALDBErrorException {
    is_member = rundata.getParameters().getBoolean("is_member");
    login_user = ALEipUtils.getALEipUser(rundata);
    groups = ALEipUtils.getMyGroups(rundata);

    authority_edit =
        MsgboardUtils.checkPermission(
            rundata,
            context,
            ALAccessControlConstants.VALUE_ACL_UPDATE,
            ALAccessControlConstants.POERTLET_FEATURE_MSGBOARD_CATEGORY_OTHER);

    authority_delete =
        MsgboardUtils.checkPermission(
            rundata,
            context,
            ALAccessControlConstants.VALUE_ACL_DELETE,
            ALAccessControlConstants.POERTLET_FEATURE_MSGBOARD_CATEGORY_OTHER);

    // スーパークラスのメソッドを呼び出す。
    super.init(action, rundata, context);
  }

  /** */
  @Override
  public void initField() {
    // カテゴリ名
    category_name = new ALStringField();
    category_name.setFieldName(ALLocalizationUtils.getl10n("MSGBOARD_CATEGORY_NAME"));
    category_name.setTrim(true);
    // メモ
    note = new ALStringField();
    note.setFieldName(ALLocalizationUtils.getl10n("MSGBOARD_MEMO"));
    note.setTrim(true);
    // 閲覧/返信フラグ
    access_flag = new ALNumberField();
    access_flag.setFieldName(ALLocalizationUtils.getl10n("MSGBOARD_CHANGE_VIEWS"));
    access_flag.setValue(0);
    // メンバーリスト
    memberList = new ArrayList<ALEipUser>();
  }

  /** 掲示板カテゴリの各フィールドに対する制約条件を設定します。 <br> */
  @Override
  protected void setValidator() {
    // カテゴリ名必須項目
    category_name.setNotNull(true);
    // カテゴリ名文字数制限
    category_name.limitMaxLength(50);
    // メモ文字数制限
    note.limitMaxLength(1000);
    // 閲覧/返信フラグ
    access_flag.limitValue(0, 3);
  }

  /**
   * 掲示板カテゴリのフォームに入力されたデータの妥当性検証を行います。 <br>
   *
   * @param msgList
   * @return
   */
  @Override
  protected boolean validate(List<String> msgList) {
    // カテゴリ名
    category_name.validate(msgList);
    // メモ
    note.validate(msgList);
    // 閲覧/返信フラグ
    access_flag.validate(msgList);

    int tmp_access_flag = (int) access_flag.getValue();
    if (tmp_access_flag == MsgboardUtils.ACCESS_PUBLIC_MEMBER
        || tmp_access_flag == MsgboardUtils.ACCESS_SEACRET_MEMBER) {
      // 所属メンバー
      if (memberList.size() == 0) {
        msgList.add("所属メンバーを選択してください。");
      }
    }

    return (msgList.size() == 0);
  }

  /**
   * 掲示板カテゴリをデータベースから読み出します。 <br>
   *
   * @param rundata
   * @param context
   * @param msgList
   * @return
   */
  @Override
  protected boolean loadFormData(RunData rundata, Context context, List<String> msgList)
      throws ALPageNotFoundException, ALDBErrorException {
    try {
      String loginUserStatus = null;
      int uid = (int) login_user.getUserId().getValue();

      // オブジェクトモデルを取得
      EipTMsgboardCategory category = MsgboardUtils.getEipTMsgboardCategory(rundata, context, true);
      if (category == null) {
        return false;
      }
      // カテゴリ名
      category_name.setValue(category.getCategoryName());
      // メモ
      note.setValue(category.getNote());
      // 公開区分
      boolean public_flag =
          (MsgboardUtils.PUBLIC_FLG_VALUE_PUBLIC).equals(category.getPublicFlag());

      // このカテゴリを共有しているメンバーを取得
      SelectQuery<EipTMsgboardCategoryMap> mapquery = Database.query(EipTMsgboardCategoryMap.class);
      Expression mapexp =
          ExpressionFactory.matchDbExp(
              EipTMsgboardCategory.CATEGORY_ID_PK_COLUMN, category.getCategoryId());
      mapquery.setQualifier(mapexp);

      List<EipTMsgboardCategoryMap> list = mapquery.fetchList();

      List<Integer> users = new ArrayList<Integer>();
      int size = list.size();
      for (int i = 0; i < size; i++) {
        EipTMsgboardCategoryMap map = list.get(i);
        users.add(map.getUserId());
        if (uid == map.getUserId().intValue()) {
          loginUserStatus = map.getStatus();
        }
      }

      SelectQuery<TurbineUser> query = Database.query(TurbineUser.class);
      Expression exp = ExpressionFactory.inDbExp(TurbineUser.USER_ID_PK_COLUMN, users);
      Expression nonDisabledexp = ExpressionFactory.noMatchExp(TurbineUser.DISABLED_PROPERTY, "T");
      query.setQualifier(exp.andExp(nonDisabledexp));
      memberList.addAll(ALEipUtils.getUsersFromSelectQuery(query));

      if (public_flag) {
        if ((MsgboardUtils.STAT_VALUE_ALL).equals(loginUserStatus)) {
          access_flag.setValue(MsgboardUtils.ACCESS_PUBLIC_ALL);
          is_member = false;
        } else {
          access_flag.setValue(MsgboardUtils.ACCESS_PUBLIC_MEMBER);
          is_member = true;
        }
      } else {
        if ((MsgboardUtils.STAT_VALUE_ALL).equals(loginUserStatus)) {
          access_flag.setValue(MsgboardUtils.ACCESS_SEACRET_SELF);
          is_member = false;
        } else {
          access_flag.setValue(MsgboardUtils.ACCESS_SEACRET_MEMBER);
          is_member = true;
        }
      }

    } catch (Exception e) {
      logger.error("[MsgboardFormData]", e);
      throw new ALDBErrorException();
    }
    return true;
  }

  /**
   * 掲示板カテゴリをデータベースに格納します。 <br>
   *
   * @param rundata
   * @param context
   * @param msgList
   * @return
   */
  @Override
  protected boolean insertFormData(RunData rundata, Context context, List<String> msgList)
      throws ALPageNotFoundException, ALDBErrorException {
    try {
      TurbineUser tuser =
          Database.get(TurbineUser.class, Integer.valueOf(ALEipUtils.getUserId(rundata)));

      // 新規オブジェクトモデル
      EipTMsgboardCategory category = Database.create(EipTMsgboardCategory.class);
      // カテゴリ名
      category.setCategoryName(category_name.getValue());
      // メモ
      category.setNote(note.getValue());
      int accessFlag = (int) access_flag.getValue();
      if (accessFlag == MsgboardUtils.ACCESS_PUBLIC_ALL
          || accessFlag == MsgboardUtils.ACCESS_PUBLIC_MEMBER) {
        category.setPublicFlag(MsgboardUtils.PUBLIC_FLG_VALUE_PUBLIC);
      } else {
        category.setPublicFlag(MsgboardUtils.PUBLIC_FLG_VALUE_NONPUBLIC);
      }

      // ユーザーID
      category.setTurbineUser(tuser);
      // 作成日
      category.setCreateDate(Calendar.getInstance().getTime());
      // 更新日
      category.setUpdateDate(Calendar.getInstance().getTime());

      int size = memberList.size();
      for (int i = 0; i < size; i++) {
        EipTMsgboardCategoryMap map = Database.create(EipTMsgboardCategoryMap.class);
        ALEipUser user = memberList.get(i);
        int userid = (int) user.getUserId().getValue();
        map.setEipTMsgboardCategory(category);
        map.setUserId(Integer.valueOf(userid));
        // O: 自カテゴリ S: 共有カテゴリ(Share)
        if (userid == ALEipUtils.getUserId(rundata)) {
          if (accessFlag == MsgboardUtils.ACCESS_PUBLIC_ALL
              || accessFlag == MsgboardUtils.ACCESS_SEACRET_SELF) {
            // 所属メンバーがログインユーザのみの場合
            map.setStatus(MsgboardUtils.STAT_VALUE_ALL);
          } else {
            map.setStatus(MsgboardUtils.STAT_VALUE_OWNER);
          }
        } else {
          map.setStatus(MsgboardUtils.STAT_VALUE_SHARE);
        }
      }

      // 掲示板カテゴリを登録
      Database.commit();

      // イベントログに保存
      ALEventlogFactoryService.getInstance()
          .getEventlogHandler()
          .log(
              category.getCategoryId(),
              ALEventlogConstants.PORTLET_TYPE_MSGBOARD_CATEGORY,
              category.getCategoryName());

    } catch (Exception e) {
      Database.rollback();
      logger.error("[MsgboardFormData]", e);
      throw new ALDBErrorException();
    }
    return true;
  }

  /**
   * データベースに格納されている掲示板カテゴリを更新します。 <br>
   *
   * @param rundata
   * @param context
   * @param msgList
   * @return
   */
  @Override
  protected boolean updateFormData(RunData rundata, Context context, List<String> msgList)
      throws ALPageNotFoundException, ALDBErrorException {
    try {
      // オブジェクトモデルを取得
      EipTMsgboardCategory category = MsgboardUtils.getEipTMsgboardCategory(rundata, context, true);
      if (category == null) {
        return false;
      }

      // カテゴリ名
      category.setCategoryName(category_name.getValue());
      // メモ
      category.setNote(note.getValue());
      // 閲覧返信フラグ
      int accessFlag = (int) access_flag.getValue();
      if (accessFlag == MsgboardUtils.ACCESS_PUBLIC_ALL
          || accessFlag == MsgboardUtils.ACCESS_PUBLIC_MEMBER) {
        category.setPublicFlag(MsgboardUtils.PUBLIC_FLG_VALUE_PUBLIC);
      } else {
        category.setPublicFlag(MsgboardUtils.PUBLIC_FLG_VALUE_NONPUBLIC);
      }
      // ユーザーID
      // category.setTurbineUser(tuser);
      // 更新日
      category.setUpdateDate(Calendar.getInstance().getTime());

      SelectQuery<EipTMsgboardCategoryMap> mapquery = Database.query(EipTMsgboardCategoryMap.class);
      Expression mapexp =
          ExpressionFactory.matchExp(
              EipTMsgboardCategoryMap.CATEGORY_ID_PROPERTY, category.getCategoryId());
      mapquery.setQualifier(mapexp);

      List<EipTMsgboardCategoryMap> maplist = mapquery.fetchList();
      Database.deleteAll(maplist);

      int size = memberList.size();
      for (int i = 0; i < size; i++) {
        EipTMsgboardCategoryMap map = Database.create(EipTMsgboardCategoryMap.class);
        ALEipUser user = memberList.get(i);
        int userid = (int) user.getUserId().getValue();
        map.setEipTMsgboardCategory(category);
        map.setUserId(Integer.valueOf(userid));
        // O: 自カテゴリ S: 共有カテゴリ(Share)
        if (userid == ALEipUtils.getUserId(rundata)) {
          if (accessFlag == MsgboardUtils.ACCESS_PUBLIC_ALL
              || accessFlag == MsgboardUtils.ACCESS_SEACRET_SELF) {
            // 所属メンバーがログインユーザのみの場合
            map.setStatus(MsgboardUtils.STAT_VALUE_ALL);
          } else {
            map.setStatus(MsgboardUtils.STAT_VALUE_OWNER);
          }
        } else {
          map.setStatus(MsgboardUtils.STAT_VALUE_SHARE);
        }
      }
      Database.commit();

      // イベントログに保存
      ALEventlogFactoryService.getInstance()
          .getEventlogHandler()
          .log(
              category.getCategoryId(),
              ALEventlogConstants.PORTLET_TYPE_MSGBOARD_CATEGORY,
              category.getCategoryName());

    } catch (Exception e) {
      Database.rollback();
      logger.error("[MsgboardFormData]", e);
      throw new ALDBErrorException();
    }
    return true;
  }

  /**
   * 掲示板カテゴリを削除します。 <br>
   *
   * @param rundata
   * @param context
   * @param msgList
   * @return
   */
  @SuppressWarnings("unchecked")
  @Override
  protected boolean deleteFormData(RunData rundata, Context context, List<String> msgList)
      throws ALPageNotFoundException, ALDBErrorException {
    try {
      // オブジェクトモデルを取得
      EipTMsgboardCategory category = MsgboardUtils.getEipTMsgboardCategory(rundata, context, true);
      if (category == null) {
        return false;
      }

      // 掲示板カテゴリを削除
      // DBテーブルのカスケード設定で,
      // トピックおよび添付ファイルのレコードも自動的に削除される.

      // イベントログに保存
      ALEventlogFactoryService.getInstance()
          .getEventlogHandler()
          .log(
              category.getCategoryId(),
              ALEventlogConstants.PORTLET_TYPE_MSGBOARD_CATEGORY,
              category.getCategoryName());

      List<EipTMsgboardTopic> topics = category.getEipTMsgboardTopics();
      for (EipTMsgboardTopic topic : topics) {
        MsgboardUtils.deleteAttachmentFiles(topic);
      }

      Database.delete(category);
      Database.commit();
      // 一覧表示画面のフィルタに設定されているカテゴリのセッション情報を削除
      String filtername = MsgboardTopicSelectData.class.getName() + ALEipConstants.LIST_FILTER;
      ALEipUtils.removeTemp(rundata, context, filtername);
    } catch (Exception e) {
      Database.rollback();
      logger.error("[MsgboardFormData]", e);
      throw new ALDBErrorException();
    }
    return true;
  }

  /**
   * @param rundata
   * @param context
   * @param msgList
   * @return
   * @throws ALPageNotFoundException
   * @throws ALDBErrorException
   */
  @Override
  protected boolean setFormData(RunData rundata, Context context, List<String> msgList)
      throws ALPageNotFoundException, ALDBErrorException {
    boolean res = super.setFormData(rundata, context, msgList);
    if (res) {
      int tmp_access_flag = (int) access_flag.getValue();
      if (tmp_access_flag == MsgboardUtils.ACCESS_PUBLIC_ALL
          || tmp_access_flag == MsgboardUtils.ACCESS_SEACRET_SELF) {
        memberList.add(login_user);
      } else {
        String str[] = rundata.getParameters().getStrings("member_to");
        if (str == null || str.length == 0) {
          return res;
        }

        boolean containsLoginUser = false;
        String str_loginuserid = login_user.getName().getValue();
        int strsize = str.length;
        for (int i = 0; i < strsize; i++) {
          if (str_loginuserid.equals(str[i])) {
            containsLoginUser = true;
            break;
          }
        }
        if (!containsLoginUser) {
          memberList.add(login_user);
        }

        SelectQuery<TurbineUser> query = Database.query(TurbineUser.class);
        Expression exp = ExpressionFactory.inExp(TurbineUser.LOGIN_NAME_PROPERTY, str);
        query.setQualifier(exp);
        memberList.addAll(ALEipUtils.getUsersFromSelectQuery(query));
      }
    }
    return res;
  }

  /**
   * カテゴリ名を取得します。 <br>
   *
   * @return
   */
  public ALStringField getCategoryName() {
    return category_name;
  }

  /**
   * メモを取得します。 <br>
   *
   * @return
   */
  public ALStringField getNote() {
    return note;
  }

  public ALNumberField getAccessFlag() {
    return access_flag;
  }

  /** @return */
  public boolean isMember() {
    return (is_member || memberList.size() > 1);
  }

  /**
   * グループメンバーを取得します。
   *
   * @return
   */
  public List<ALEipUser> getMemberList() {
    return memberList;
  }

  /**
   * 指定したグループ名のユーザーを取得します。
   *
   * @param groupname
   * @return
   */
  public List<ALEipUser> getUsers(String groupname) {
    return ALEipUtils.getUsers(groupname);
  }

  /**
   * グループリストを取得します。
   *
   * @return
   */
  public List<ALEipGroup> getGroupList() {
    return groups;
  }

  /**
   * ログインユーザを取得します。
   *
   * @return
   */
  public ALEipUser getLoginUser() {
    return login_user;
  }

  public boolean getAuthorityEdit() {
    return authority_edit;
  }

  public boolean getAuthorityDelete() {
    return authority_delete;
  }

  /**
   * アクセス権限チェック用メソッド。 アクセス権限の機能名を返します。
   *
   * @return
   */
  @Override
  public String getAclPortletFeature() {
    return ALAccessControlConstants.POERTLET_FEATURE_MSGBOARD_CATEGORY;
  }
}
コード例 #22
0
ファイル: ALBaseUser.java プロジェクト: aipocom/aipo
/** ユーザー情報を表すクラスです。 <br> */
public class ALBaseUser extends org.apache.jetspeed.om.security.BaseJetspeedUser {

  /** */
  private static final long serialVersionUID = -5919528447748101476L;

  public static final String IN_TELEPHONE = "IN_TELEPHONE";

  public static final String OUT_TELEPHONE = "OUT_TELEPHONE";

  public static final String CELLULAR_PHONE = "CELLULAR_PHONE";

  public static final String CELLULAR_MAIL = "CELLULAR_MAIL";

  public static final String CELLULAR_UID = "CELLULAR_UID";

  public static final String COMPANY_ID = "COMPANY_ID";

  public static final String POST_ID = "POST_ID";

  public static final String POSITION_ID = "POSITION_ID";

  public static final String FIRST_NAME_KANA = "FIRST_NAME_KANA";

  public static final String LAST_NAME_KANA = "LAST_NAME_KANA";

  public static final String PHOTO = "PHOTO";

  public static final String PHOTO_SMARTPHONE = "PHOTO_SMARTPHONE";

  public static final String CREATED_USER_ID = "CREATED_USER_ID";

  public static final String UPDATED_USER_ID = "UPDATED_USER_ID";

  public static final String CREATED = "CREATED";

  public static final String MODIFIED = "MODIFIED";

  public static final String PHOTO_MODIFIED = "PHOTO_MODIFIED";

  public static final String PHOTO_MODIFIED_SMARTPHONE = "PHOTO_MODIFIED_SMARTPHONE";

  public static final String HAS_PHOTO = "HAS_PHOTO";

  public static final String PHOTO_TYPE = "PHOTO_TYPE";

  public static final String HAS_PHOTO_SMARTPHONE = "HAS_PHOTO_SMARTPHONE";

  public static final String MIGRATE_VERSION = "MIGRATE_VERSION";

  public static final String CODE = "CODE";

  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(ALBaseUser.class.getName());

  // セッションに保存されないデータ
  private transient Map<String, Object> map = null;

  /** */
  public ALBaseUser() {
    super();
    map = new HashMap<String, Object>();
  }

  public Object getImperm(String name) {
    return map.get(name);
  }

  public Map<String, Object> getImpermStorage() {
    if (this.map == null) {
      this.map = new HashMap<String, Object>();
    }
    return this.map;
  }

  public void setImperm(String name, Object value) {
    if (value == null) {
      map.put(name, "");
    } else {
      map.put(name, value);
    }
  }

  /** @return */
  public String getInTelephone() {
    return (String) getImperm(IN_TELEPHONE);
  }

  /** @param str */
  public void setInTelephone(String str) {
    setImperm(IN_TELEPHONE, str);
  }

  /** @return */
  public String getOutTelephone() {
    return (String) getImperm(OUT_TELEPHONE);
  }

  /** @param str */
  public void setOutTelephone(String str) {
    setImperm(OUT_TELEPHONE, str);
  }

  /** @return */
  public String getCellularPhone() {
    return (String) getImperm(CELLULAR_PHONE);
  }

  /** @param str */
  public void setCellularPhone(String str) {
    setImperm(CELLULAR_PHONE, str);
  }

  /** @return */
  public String getCellularMail() {
    return (String) getImperm(CELLULAR_MAIL);
  }

  /** @param str */
  public void setCellularMail(String str) {
    setImperm(CELLULAR_MAIL, str);
  }

  /** @return */
  public int getCompanyId() {
    return ((Integer) (getPerm(COMPANY_ID))).intValue();
  }

  /** @param str */
  public void setCompanyId(int id) {
    setPerm(COMPANY_ID, Integer.valueOf(id));
  }

  /** @return */
  public int getPostId() {
    return ((Integer) (getPerm(POST_ID))).intValue();
  }

  /** @param str */
  public void setPostId(int id) {
    setPerm(POST_ID, Integer.valueOf(id));
  }

  /** @return */
  public int getPositionId() {
    return ((Integer) (getPerm(POSITION_ID))).intValue();
  }

  /** @param str */
  public void setPositionId(int id) {
    setPerm(POSITION_ID, Integer.valueOf(id));
  }

  /** @return */
  public String getFirstNameKana() {
    return (String) getImperm(FIRST_NAME_KANA);
  }

  /** @param str */
  public void setFirstNameKana(String str) {
    setImperm(FIRST_NAME_KANA, str);
  }

  /** @return */
  public String getLastNameKana() {
    return (String) getImperm(LAST_NAME_KANA);
  }

  /** @param str */
  public void setLastNameKana(String str) {
    setImperm(LAST_NAME_KANA, str);
  }

  /** @return byte[] */
  public byte[] getPhoto() {
    Object obj = getImperm(PHOTO);

    if (obj instanceof byte[]) {
      return (byte[]) obj;
    }

    if (obj == null || "".equals(obj)) {
      return null;
    }

    try {
      return ((String) obj).getBytes(ALEipConstants.DEF_CONTENT_ENCODING);
    } catch (UnsupportedEncodingException e) {
      logger.error("ALBaseUser.getPhoto", e);
      return ((String) obj).getBytes();
    }
  }

  /** @return byte[] */
  public byte[] getPhotoSmartphone() {
    Object obj = getImperm(PHOTO_SMARTPHONE);

    if (obj instanceof byte[]) {
      return (byte[]) obj;
    }

    if (obj == null || "".equals(obj)) {
      return null;
    }

    try {
      return ((String) obj).getBytes(ALEipConstants.DEF_CONTENT_ENCODING);
    } catch (UnsupportedEncodingException e) {
      logger.error("ALBaseUser.getPhotoSmartphone", e);
      return ((String) obj).getBytes();
    }
  }

  /** @param v */
  public void setPhoto(byte[] v) {
    setImperm(PHOTO, v);
  }

  /** @param b */
  public void setPhotoSmartphone(byte[] b) {
    setImperm(PHOTO_SMARTPHONE, b);
  }

  /** @return */
  public int getCreatedUserId() {
    return ((Integer) (getPerm(CREATED_USER_ID))).intValue();
  }

  /** @param id */
  public void setCreatedUserId(int id) {
    setPerm(CREATED_USER_ID, Integer.valueOf(id));
  }

  /** @return */
  public int getUpdatedUserId() {
    return ((Integer) (getPerm(UPDATED_USER_ID))).intValue();
  }

  /** @param id */
  public void setUpdatedUserId(int id) {
    setPerm(UPDATED_USER_ID, Integer.valueOf(id));
  }

  /** @param d */
  public void setCreated(Date d) {
    setPerm(CREATED, d);
  }

  /** @return */
  public Date getCreated() {
    return (Date) (getPerm(CREATED));
  }

  /** @param d */
  public void setModified(Date d) {
    setPerm(MODIFIED, d);
  }

  /** @return */
  public Date getModified() {
    return (Date) (getPerm(MODIFIED));
  }

  /**
   * 会社名を取得します。
   *
   * @param id 会社ID
   * @return 会社名
   */
  public String getCompanyName(int id) {
    String companyName = "";
    Map<Integer, ALEipCompany> companyMap = ALEipManager.getInstance().getCompanyMap();
    ALEipCompany company = companyMap.get(Integer.valueOf(id));
    if (company != null) {
      companyName = company.getCompanyName().toString();
    }
    return companyName;
  }

  /** 携帯電話の固有 ID を取得する. */
  public String getCelluarUId() {
    return (String) getImperm(CELLULAR_UID);
  }

  /** */
  public void setCelluarUId(String str) {
    setImperm(CELLULAR_UID, str);
  }

  /**
   * 最終アクセス時間を取得します。
   *
   * @return
   */
  public String getLastAccessTime() {
    StringBuffer str = new StringBuffer();
    Calendar cal = Calendar.getInstance();
    cal.setTime(super.getLastAccessDate());
    return str.append(cal.get(Calendar.YEAR))
        .append(ALLocalizationUtils.getl10n("COMMON_YEAR"))
        .append((cal.get(Calendar.MONTH) + 1))
        .append(ALLocalizationUtils.getl10n("COMMON_MONTH"))
        .append(cal.get(Calendar.DATE))
        .append(ALLocalizationUtils.getl10n("COMMON_DAY"))
        .append(cal.get(Calendar.HOUR_OF_DAY))
        .append(ALLocalizationUtils.getl10n("COMMON_HOUR"))
        .append(cal.get(Calendar.MINUTE))
        .append(ALLocalizationUtils.getl10n("COMMON_MINUTE"))
        .toString();
  }

  /**
   * 指定されたユーザが管理者権限を持っているかを返します。
   *
   * @return
   */
  public boolean isAdmin() {
    return ALEipUtils.isAdmin(Integer.parseInt(this.getUserId()));
  }

  public boolean hasPhoto() {
    String hasPhoto = (String) getPerm(HAS_PHOTO);
    return "T".equals(hasPhoto) || "N".equals(hasPhoto);
  }

  public String hasPhotoString() {
    return (String) getPerm(HAS_PHOTO);
  }

  public boolean hasPhotoSmartphone() {
    String hasPhotoSmartphone = (String) getPerm(HAS_PHOTO_SMARTPHONE);
    return "T".equals(hasPhotoSmartphone) || "N".equals(hasPhotoSmartphone);
  }

  public String hasPhotoSmartphoneString() {
    return (String) getPerm(HAS_PHOTO_SMARTPHONE);
  }

  /** */
  public void setHasPhoto(String hasPhoto) {
    setPerm(HAS_PHOTO, hasPhoto);
  }

  /** */
  public void setHasPhotoSmartphone(String hasPhotoSmartphone) {
    setPerm(HAS_PHOTO_SMARTPHONE, hasPhotoSmartphone);
  }

  /** @param d */
  public void setPhotoModified(Date d) {
    setPerm(PHOTO_MODIFIED, d);
  }

  /** @param dd */
  public void setPhotoModifiedSmartphone(Date dd) {
    setPerm(PHOTO_MODIFIED_SMARTPHONE, dd);
  }

  /** @return */
  public Date getPhotoModified() {
    return (Date) (getPerm(PHOTO_MODIFIED));
  }

  /** @return */
  public Date getPhotoModifiedSmartphone() {
    if (getPerm(PHOTO_MODIFIED_SMARTPHONE) == null
        || "".equals(getPerm(PHOTO_MODIFIED_SMARTPHONE))) {
      return null;
    }
    return (Date) (getPerm(PHOTO_MODIFIED_SMARTPHONE));
  }

  /** */
  public int getMigrateVersion() {
    return ((Integer) (getPerm(MIGRATE_VERSION))).intValue();
  }

  /** */
  public void setMigrateVersion(int id) {
    setPerm(MIGRATE_VERSION, Integer.valueOf(id));
  }

  /** */
  public String getCode() {
    return (String) getPerm(CODE);
  }

  /** */
  public void setCode(String code) {
    setPerm(CODE, code);
  }

  @Override
  public Date getPasswordChanged() {
    try {
      return super.getPasswordChanged();
    } catch (ClassCastException ignore) {
      return null;
    }
  }
}
コード例 #23
0
/** タイムカード集計の検索データを管理するためのクラスです。 */
public class TimecardSettingsSelectData
    extends ALAbstractSelectData<EipTTimecardSettings, EipTTimecardSettings> {

  /** logger */
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(TimecardSettingsSelectData.class.getName());

  /**
   * @param rundata
   * @param context
   * @return
   */
  @Override
  protected ResultList<EipTTimecardSettings> selectList(RunData rundata, Context context) {
    return null;
  }

  /**
   * @param rundata
   * @param context
   * @return
   */
  @Override
  protected EipTTimecardSettings selectDetail(RunData rundata, Context context) {
    return TimecardUtils.getEipTTimecardSettings(rundata, context);
  }

  /**
   * @param obj
   * @return
   */
  @Override
  protected Object getResultData(EipTTimecardSettings obj) {
    return null;
  }

  /**
   * @param record
   * @return
   */
  @Override
  protected Object getResultDataDetail(EipTTimecardSettings record) {
    try {
      TimecardSettingsResultData rd = new TimecardSettingsResultData();
      rd.initField();
      rd.setTimecardSettingsId(record.getTimecardSettingsId().intValue());
      rd.setStartTime(record.getStartHour() + "時" + record.getStartMinute() + "分");
      rd.setEndTime(record.getEndHour() + "時" + record.getEndMinute() + "分");
      rd.setWorktimeIn(record.getWorktimeIn().intValue());
      rd.setWorktimeOut(record.getWorktimeOut().intValue());
      rd.setResttimeIn(record.getResttimeIn().intValue());
      rd.setResttimeOut(record.getResttimeOut().intValue());

      return rd;
    } catch (Exception ex) {
      logger.error("timecard", ex);
      return null;
    }
  }

  /** */
  @Override
  protected Attributes getColumnMap() {
    return null;
  }
}
コード例 #24
0
/**  役職を管理するフォームデータを管理するクラスです。 <br> */
public class AccountPositionFormData extends ALAbstractFormData {

  /** logger */
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(AccountPositionFormData.class.getName());

  /** 役職名 */
  private ALStringField position_name;

  /** 役職ID */
  private int position_id;

  /**
   * 初期化します。
   *
   * @param action
   * @param rundata
   * @param context
   */
  @Override
  public void init(ALAction action, RunData rundata, Context context)
      throws ALPageNotFoundException, ALDBErrorException {
    super.init(action, rundata, context);
  }

  /** 各フィールドを初期化します。 <br> */
  @Override
  public void initField() {

    // 役職名
    position_name = new ALStringField();
    position_name.setFieldName("役職名");
    position_name.setTrim(true);
  }

  /** 各フィールドに対する制約条件を設定します。 <br> */
  @Override
  protected void setValidator() {
    position_name.setNotNull(true);
    position_name.limitMaxLength(50);
  }

  /**
   * @param rundata
   * @param context
   * @param msgList
   * @return
   */
  @Override
  protected boolean setFormData(RunData rundata, Context context, List<String> msgList)
      throws ALPageNotFoundException, ALDBErrorException {
    boolean res = super.setFormData(rundata, context, msgList);
    if (res) {
      try {
        if (ALEipConstants.MODE_UPDATE.equals(getMode())) {
          position_id =
              Integer.parseInt(ALEipUtils.getTemp(rundata, context, ALEipConstants.ENTITY_ID));
        }
      } catch (Exception ex) {
        logger.error("AccountPositionFormData.setFormData", ex);
      }
    }
    return res;
  }

  /**
   * フォームに入力されたデータの妥当性検証を行います。 <br>
   *
   * @param msgList
   * @return
   */
  @Override
  protected boolean validate(List<String> msgList) {
    position_name.validate(msgList);

    try {
      SelectQuery<EipMPosition> query = Database.query(EipMPosition.class);

      if (ALEipConstants.MODE_INSERT.equals(getMode())) {
        Expression exp =
            ExpressionFactory.matchExp(
                EipMPosition.POSITION_NAME_PROPERTY, position_name.getValue());
        query.setQualifier(exp);
      } else if (ALEipConstants.MODE_UPDATE.equals(getMode())) {
        Expression exp1 =
            ExpressionFactory.matchExp(
                EipMPosition.POSITION_NAME_PROPERTY, position_name.getValue());
        query.setQualifier(exp1);
        Expression exp2 =
            ExpressionFactory.noMatchDbExp(
                EipMPosition.POSITION_ID_PK_COLUMN, Integer.valueOf(position_id));
        query.andQualifier(exp2);
      }

      if (query.fetchList().size() != 0) {
        msgList.add(ALLocalizationUtils.getl10nFormat("ACCOUNT_VALIDATE_POSITION", position_name));
      }
    } catch (Exception ex) {
      logger.error("AccountPositionFormData.validate", ex);
      return false;
    }

    return (msgList.size() == 0);
  }

  /**
   * 『役職』を読み込みます。 <br>
   *
   * @param rundata
   * @param context
   * @param msgList
   * @return
   */
  @Override
  protected boolean loadFormData(RunData rundata, Context context, List<String> msgList) {
    try {
      // オブジェクトモデルを取得
      EipMPosition record = AccountUtils.getEipMPosition(rundata, context);
      if (record == null) {
        return false;
      }
      position_name.setValue(record.getPositionName());
    } catch (Exception ex) {
      logger.error("AccountPositionFormData.loadFormData", ex);
      return false;
    }
    return true;
  }

  /**
   * 『役職』を追加します。 <br>
   *
   * @param rundata
   * @param context
   * @param msgList
   * @return
   */
  @Override
  protected boolean insertFormData(RunData rundata, Context context, List<String> msgList) {
    try {

      EipMPosition position = Database.create(EipMPosition.class);
      position.setPositionName(position_name.getValue());
      Date now = new Date();
      position.setCreateDate(now);
      position.setUpdateDate(now);
      Database.commit();

      // イベントログに保存
      ALEventlogFactoryService.getInstance()
          .getEventlogHandler()
          .log(
              position.getPositionId(),
              ALEventlogConstants.PORTLET_TYPE_ACCOUNT,
              "役職「" + position.getPositionName() + "」を追加");

      position_id = position.getPositionId().intValue();

      ALEipManager.getInstance().reloadPosition();
    } catch (Exception ex) {
      Database.rollback();
      logger.error("AccountPositionFormData.insertFormData", ex);
      return false;
    }
    return true;
  }

  /**
   * 『役職』を更新します。 <br>
   *
   * @param rundata
   * @param context
   * @param msgList
   * @return
   */
  @Override
  protected boolean updateFormData(RunData rundata, Context context, List<String> msgList) {
    try {
      // オブジェクトモデルを取得
      EipMPosition record = AccountUtils.getEipMPosition(rundata, context);
      if (record == null) {
        return false;
      }
      record.setPositionName(position_name.getValue());
      record.setUpdateDate(new Date());
      Database.commit();

      // イベントログに保存
      ALEventlogFactoryService.getInstance()
          .getEventlogHandler()
          .log(
              record.getPositionId(),
              ALEventlogConstants.PORTLET_TYPE_ACCOUNT,
              "役職「" + record.getPositionName() + "」を更新");

      ALEipManager.getInstance().reloadPosition();
    } catch (Exception ex) {
      Database.rollback();
      logger.error("AccountPositionFormData.updateFormData", ex);
      return false;
    }
    return true;
  }

  /**
   * 『役職』を削除します。 <br>
   *
   * @param rundata
   * @param context
   * @param msgList
   * @return
   */
  @Override
  protected boolean deleteFormData(RunData rundata, Context context, List<String> msgList) {
    try {
      // オブジェクトモデルを取得
      EipMPosition record = AccountUtils.getEipMPosition(rundata, context);
      if (record == null) {
        return false;
      }

      // 役職IDを取得
      int positionId = record.getPositionId();

      // 役職を削除
      Database.delete(record);
      Database.commit();

      // イベントログに保存
      ALEventlogFactoryService.getInstance()
          .getEventlogHandler()
          .log(
              record.getPositionId(),
              ALEventlogConstants.PORTLET_TYPE_ACCOUNT,
              "役職「" + record.getPositionName() + "」を削除");

      // この役職に設定されているユーザーの役職IDを0とする
      String sql = "UPDATE turbine_user set POSITION_ID = 0 where POSITION_ID = " + positionId;
      Database.sql(TurbineUser.class, sql).execute();

      ALEipManager.getInstance().reloadPosition();
    } catch (Exception ex) {
      Database.rollback();
      logger.error("AccountPositionFormData.deleteFormData", ex);
      return false;
    }
    return true;
  }

  /**
   * 『役職名』を取得します。 <br>
   *
   * @return
   */
  public ALStringField getPositionName() {
    return position_name;
  }

  /** @return */
  public int getPositionId() {
    return position_id;
  }
}
コード例 #25
0
/** 1日スケジュール(グループ)の検索結果を管理するクラスです。 */
public class ScheduleOnedayGroupSelectData extends ScheduleOnedaySelectData {

  /** <code>logger</code> logger */
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(ScheduleOnedayGroupSelectData.class.getName());

  /** <code>termmap</code> 期間スケジュールマップ */
  private Map<Integer, List<ScheduleOnedayResultData>> termmap;

  /** <code>map</code> スケジュールMap */
  private Map<Integer, ScheduleOnedayContainer> map;

  /** <code>members</code> 共有メンバー */
  private List<ALEipUser> members;

  /** <code>groups</code> グループリスト */
  private List<ALEipGroup> groups;

  /** <code>groups</code> グループリスト */
  private List<ALEipGroup> facilitiyGroups;

  /** <code>userid</code> ユーザーID */
  private int userid;

  /** <code>rows</code> rows */
  private int rows[];

  /** <code>max</code> max */
  private int max;

  /** <code>is_hasspan</code> 期間スケジュールがあるかどうか */
  private boolean is_hasspan;

  /** <code>myGroupURI</code> ポートレット MyGroup へのリンク */
  private String myGroupURI;

  /** <code>todomap</code> ToDo マップ */
  private Map<Integer, List<ScheduleToDoResultData>> todomap;

  /** ポートレット ID */
  private String portletId;

  /** <code>map</code> スケジュールMap(設備) */
  private Map<Integer, ScheduleOnedayContainer> facilitymap;

  private List<FacilityResultData> facilityList;

  /** <code>hasAuthoritySelfInsert</code> アクセス権限 */
  private boolean hasAuthoritySelfInsert = false;

  /** <code>hasAuthorityFacilityInsert</code> アクセス権限 */
  private boolean hasAuthorityFacilityInsert = false;

  private boolean hasAclviewOther = false;

  /** <code>target_group_name</code> グループ名 */
  private TurbineGroup target_group_name;

  /**
   * @param action
   * @param rundata
   * @param context
   * @throws ALPageNotFoundException
   * @throws ALDBErrorException
   */
  @Override
  public void init(ALAction action, RunData rundata, Context context)
      throws ALPageNotFoundException, ALDBErrorException {
    super.init(action, rundata, context);

    if (rundata.getParameters().containsKey(ALEipConstants.LIST_FILTER)) {
      ALEipUtils.setTemp(
          rundata,
          context,
          ScheduleUtils.FILTER_NAMESPACE,
          rundata.getParameters().getString(ALEipConstants.LIST_FILTER));
    }
    if (rundata.getParameters().containsKey(ALEipConstants.LIST_FILTER_TYPE)) {
      ALEipUtils.setTemp(
          rundata,
          context,
          ScheduleUtils.FILTER_NAMESPACE_TYPE,
          rundata.getParameters().getString(ALEipConstants.LIST_FILTER_TYPE));
    }

    viewtype = "oneday-group";
    try {
      termmap = new LinkedHashMap<Integer, List<ScheduleOnedayResultData>>();
      map = new LinkedHashMap<Integer, ScheduleOnedayContainer>();
      todomap = new LinkedHashMap<Integer, List<ScheduleToDoResultData>>();
      facilitymap = new LinkedHashMap<Integer, ScheduleOnedayContainer>();

      groups = ALEipUtils.getMyGroups(rundata);
      facilitiyGroups = ALEipUtils.getALEipGroups();
      userid = ALEipUtils.getUserId(rundata);
      rows = new int[(endHour - startHour) * 12 + 1];
      int size = rows.length;
      for (int i = 0; i < size; i++) {
        rows[i] = 1;
      }
      String filter = ALEipUtils.getTemp(rundata, context, ScheduleUtils.FILTER_NAMESPACE);

      target_group_name = getGroup(filter);

      if (filter == null) {
        VelocityPortlet portlet = ALEipUtils.getPortlet(rundata, context);
        String groupName = portlet.getPortletConfig().getInitParameter("p3a-group");
        if (groupName != null) {
          ALEipUtils.setTemp(rundata, context, ScheduleUtils.FILTER_NAMESPACE, groupName);
          ALEipUtils.setTemp(rundata, context, ScheduleUtils.FILTER_NAMESPACE_TYPE, "group");
        }
      }

      // ポートレット MyGroup のへのリンクを取得する.
      myGroupURI = ScheduleUtils.getPortletURIinPersonalConfigPane(rundata, "MyGroup");

      // アクセス権限
      ALAccessControlFactoryService aclservice =
          (ALAccessControlFactoryService)
              ((TurbineServices) TurbineServices.getInstance())
                  .getService(ALAccessControlFactoryService.SERVICE_NAME);
      ALAccessControlHandler aclhandler = aclservice.getAccessControlHandler();

      hasAclviewOther =
          aclhandler.hasAuthority(
              userid,
              ALAccessControlConstants.POERTLET_FEATURE_SCHEDULE_OTHER,
              ALAccessControlConstants.VALUE_ACL_LIST);

      hasAuthoritySelfInsert =
          aclhandler.hasAuthority(
              userid,
              ALAccessControlConstants.POERTLET_FEATURE_SCHEDULE_SELF,
              ALAccessControlConstants.VALUE_ACL_INSERT);

      hasAuthorityFacilityInsert =
          aclhandler.hasAuthority(
              userid,
              ALAccessControlConstants.POERTLET_FEATURE_SCHEDULE_FACILITY,
              ALAccessControlConstants.VALUE_ACL_INSERT);

    } catch (Exception ex) {
      logger.error("[ScheduleOnedayGroupSelectData]", ex);
    }
  }

  @Override
  protected ResultList<VEipTScheduleList> selectList(RunData rundata, Context context)
      throws ALPageNotFoundException, ALDBErrorException {
    try {
      List<VEipTScheduleList> resultBaseList = getScheduleList(rundata, context);
      List<VEipTScheduleList> resultList = ScheduleUtils.sortByDummySchedule(resultBaseList);

      List<VEipTScheduleList> list = new ArrayList<VEipTScheduleList>();
      List<VEipTScheduleList> delList = new ArrayList<VEipTScheduleList>();
      int delSize = 0;
      int resultSize = resultList.size();
      int size = 0;
      boolean canAdd = true;
      for (int i = 0; i < resultSize; i++) {
        VEipTScheduleList record = resultList.get(i);
        delList.clear();
        canAdd = true;
        size = list.size();
        for (int j = 0; j < size; j++) {
          VEipTScheduleList record2 = list.get(j);
          if (!record.getRepeatPattern().equals("N")
              && "D".equals(record2.getStatus())
              && record.getScheduleId().intValue() == record2.getParentId().intValue()
              && record.getUserId().intValue() == record2.getUserId().intValue()) {
            canAdd = false;
            break;
          }
          if (!record2.getRepeatPattern().equals("N")
              && "D".equals(record.getStatus())
              && record2.getScheduleId().intValue() == record.getParentId().intValue()
              && record2.getUserId().intValue() == record.getUserId().intValue()) {
            // [繰り返しスケジュール] 親の ID を検索
            if (!delList.contains(record2)) {
              delList.add(record2);
            }
            canAdd = true;
          }
        }
        delSize = delList.size();
        for (int k = 0; k < delSize; k++) {
          list.remove(delList.get(k));
        }

        if (canAdd) {
          list.add(record);
        }
      }

      // ダミーを削除する.
      delList.clear();
      size = list.size();
      for (int i = 0; i < size; i++) {
        VEipTScheduleList record = list.get(i);
        if ("D".equals(record.getStatus())) {
          delList.add(record);
        }
      }
      delSize = delList.size();
      for (int i = 0; i < delSize; i++) {
        list.remove(delList.get(i));
      }

      // ソート
      Collections.sort(
          list,
          new Comparator<VEipTScheduleList>() {

            @Override
            public int compare(VEipTScheduleList a, VEipTScheduleList b) {
              Calendar cal = Calendar.getInstance();
              Calendar cal2 = Calendar.getInstance();
              cal.setTime(a.getStartDate());
              cal.set(0, 0, 0);
              cal2.setTime(b.getStartDate());
              cal2.set(0, 0, 0);
              if ((cal.getTime()).compareTo(cal2.getTime()) != 0) {
                return (cal.getTime()).compareTo(cal2.getTime());
              } else {
                cal.setTime(a.getEndDate());
                cal.set(0, 0, 0);
                cal2.setTime(b.getEndDate());
                cal2.set(0, 0, 0);

                return (cal.getTime()).compareTo(cal2.getTime());
              }
            }
          });

      if (viewToDo == 1) {
        // ToDo の読み込み
        loadToDo(rundata, context);
      }

      return new ResultList<VEipTScheduleList>(list);
    } catch (Exception e) {
      logger.error("[ScheduleOnedayGroupSelectData]", e);
      throw new ALDBErrorException();
    }
  }

  protected List<VEipTScheduleList> getScheduleList(RunData rundata, Context context) {

    Calendar cal = Calendar.getInstance();
    cal.setTime(getViewDate().getValue());
    cal.add(Calendar.DATE, 1);
    cal.add(Calendar.MILLISECOND, -1);
    ALDateTimeField field = new ALDateTimeField();
    field.setValue(cal.getTime());

    String filter = ALEipUtils.getTemp(rundata, context, ScheduleUtils.FILTER_NAMESPACE);
    String filter_type = ALEipUtils.getTemp(rundata, context, ScheduleUtils.FILTER_NAMESPACE_TYPE);

    if ("all".equals(filter)) {
      filter = filter_type = null;
      ALEipUtils.removeTemp(rundata, context, ScheduleUtils.FILTER_NAMESPACE);
      ALEipUtils.removeTemp(rundata, context, ScheduleUtils.FILTER_NAMESPACE_TYPE);
    }

    if (filter == null || filter_type == null || filter.equals("") || tmpViewDate2 != null) {

      members = new ArrayList<ALEipUser>();
      members.add(ALEipUtils.getALEipUser(rundata));
      ScheduleOnedayContainer con = new ScheduleOnedayContainer();
      con.initField();
      con.initHour(startHour, endHour);
      Integer uid = Integer.valueOf(ALEipUtils.getUserId(rundata));
      this.termmap.put(uid, new ArrayList<ScheduleOnedayResultData>());
      this.map.put(uid, con);
      this.todomap.put(uid, new ArrayList<ScheduleToDoResultData>());
      return ScheduleUtils.getScheduleList(
          userid, getViewDate().getValue(), field.getValue(), Arrays.asList(userid), null);
    }

    // グループ名からユーザを取得
    List<Integer> ulist = ALEipUtils.getUserIds(filter);

    // グループにユーザが存在しない場合はダミーユーザを設定し、検索します。(0件ヒット)
    // ダミーユーザーID = -1
    int size = ulist.size();
    if (size == 0) {
      ulist.add(Integer.valueOf(-1));
    } else {
      for (int i = 0; i < size; i++) {
        Integer id = ulist.get(i);
        ScheduleOnedayContainer con = new ScheduleOnedayContainer();
        con.initField();
        con.initHour(startHour, endHour);
        this.termmap.put(id, new ArrayList<ScheduleOnedayResultData>());
        this.map.put(id, con);
        this.todomap.put(id, new ArrayList<ScheduleToDoResultData>());
      }
    }

    // List facilityIds = FacilitiesUtils.getFacilityIds(filter);
    List<Integer> facilityIds = null;
    String[] filteres = filter.split(";");
    if ("Facility".equals(filter)) {
      facilityIds = getFacilityIdAllList();
    } else if (("group".equals(filter_type)) && !("f".equals(filteres[0]))) {
      facilityIds = FacilitiesUtils.getFacilityIds(filteres[0]);
    } else {
      if ("f".equals(filteres[0])) {
        facilityIds = FacilitiesUtils.getFacilityGroupIds(Integer.valueOf(filteres[1]));
      } else {
        if (ScheduleUtils.isNumberValue(filter)) {
          facilityIds = FacilitiesUtils.getFacilityGroupIds(Integer.valueOf(filter));
        } else {
          facilityIds = new ArrayList<Integer>();
          String[] split = filter.split(",");
          if (split.length == 2) {
            // URLパラメータにfilterが含まれてしまっていた場合
            // デフォルト値のセットしなおし
            // facilityIds初期化
            VelocityPortlet portlet = ALEipUtils.getPortlet(rundata, context);
            String groupName = portlet.getPortletConfig().getInitParameter("p3a-group");
            if (groupName != null) {
              ALEipUtils.setTemp(rundata, context, ScheduleUtils.FILTER_NAMESPACE, groupName);
              ALEipUtils.setTemp(rundata, context, ScheduleUtils.FILTER_NAMESPACE_TYPE, "group");
            }
          }
        }
      }
    }

    int f_size = facilityIds.size();
    if (f_size == 0) {
      facilityIds.add(Integer.valueOf(-1));
    } else {
      for (int i = 0; i < f_size; i++) {
        Integer id = facilityIds.get(i);
        ScheduleOnedayContainer con = new ScheduleOnedayContainer();
        con.initField();
        con.initHour(startHour, endHour);
        this.facilitymap.put(id, con);
      }
    }

    members = ALEipUtils.getUsers(filter);

    String flag_changeturn =
        ALEipUtils.getTemp(rundata, context, ScheduleUtils.FLAG_CHANGE_TURN_STR);
    if ("0".equals(flag_changeturn)) {
      // ログインユーザの行けジュールを一番上に表示させるため,
      // メンバリストの初めの要素にログインユーザを配置する.
      ALEipUser eipUser = null;
      int memberSize = members.size();
      for (int i = 0; i < memberSize; i++) {
        eipUser = members.get(i);
        if (eipUser.getUserId().getValue() == userid) {
          members.remove(i);
          members.add(0, eipUser);
        }
      }
    }
    if ("Facility".equals(filter)) {
      facilityList = FacilitiesUtils.getFacilityList(filter);
    } else if ("facilitygroup".equals(filter_type) || "f".equals(filteres[0])) {
      if ("f".equals(filteres[0])) {
        facilityList = FacilitiesUtils.getFacilityGroupList(Integer.valueOf(filteres[1]));

      } else {

        if (ScheduleUtils.isNumberValue(filter)) {
          facilityList = FacilitiesUtils.getFacilityGroupList(Integer.valueOf(filter));
        }
      }
    } else {
      facilityList = FacilitiesUtils.getFacilityList(filter);
    }
    if (!("f".equals(filteres[0]))) {
      current_filter = filter;
    } else {
      current_filter = filteres[1];
    }
    current_filter_type = filter_type;
    return ScheduleUtils.getScheduleList(
        userid, getViewDate().getValue(), field.getValue(), ulist, facilityIds);
  }

  private List<Integer> getFacilityIdAllList() {
    List<Integer> facilityIdAllList = new ArrayList<Integer>();

    try {
      SelectQuery<EipMFacility> query = Database.query(EipMFacility.class);
      query.select(EipMFacility.FACILITY_ID_PK_COLUMN);
      List<EipMFacility> aList = query.fetchList();

      int size = aList.size();
      for (int i = 0; i < size; i++) {
        EipMFacility record = aList.get(i);
        facilityIdAllList.add(record.getFacilityId());
      }
    } catch (Exception ex) {
      logger.error("schedule", ex);
    }
    return facilityIdAllList;
  }

  /**
   * @param record
   * @return
   * @throws ALPageNotFoundException
   * @throws ALDBErrorException
   */
  @Override
  protected Object getResultData(VEipTScheduleList record)
      throws ALPageNotFoundException, ALDBErrorException {
    ScheduleOnedayResultData rd = new ScheduleOnedayResultData();
    rd.initField();
    try {
      if ("R".equals(record.getStatus())) {
        return rd;
      }
      if (!ScheduleUtils.isView(
          getViewDate(), record.getRepeatPattern(), record.getStartDate(), record.getEndDate())) {
        return rd;
      }

      boolean is_member = record.isMember();

      // Dummy スケジュールではない
      // 完全に隠す
      // 自ユーザー以外
      // 共有メンバーではない
      // オーナーではない
      if ((!"D".equals(record.getStatus()))
          && "P".equals(record.getPublicFlag())
          && (userid != record.getUserId().intValue())
          && (userid != record.getOwnerId().intValue())
          && !is_member) {
        return rd;
      } else if (!hasAclviewOther && !is_member) { // 閲覧権限がなく、グループでもない
        return rd;
      }
      if ("C".equals(record.getPublicFlag())
          && (userid != record.getUserId().intValue())
          && (userid != record.getOwnerId().intValue())
          && !is_member) {
        rd.setName(ALLocalizationUtils.getl10n("SCHEDULE_CLOSE_PUBLIC_WORD"));
        // 仮スケジュールかどうか
        rd.setTmpreserve(false);
      } else {
        rd.setName(record.getName());
        // 仮スケジュールかどうか
        rd.setTmpreserve("T".equals(record.getStatus()));
      }
      // ID
      rd.setScheduleId(record.getScheduleId().intValue());
      // 親スケジュール ID
      rd.setParentId(record.getParentId().intValue());
      // 開始日時
      rd.setStartDate(record.getStartDate());
      // 終了日時
      rd.setEndDate(record.getEndDate());
      // 公開するかどうか
      rd.setPublic("O".equals(record.getPublicFlag()));
      // 非表示にするかどうか
      rd.setHidden("P".equals(record.getPublicFlag()));
      // ダミーか
      rd.setDummy("D".equals(record.getStatus()));
      // ログインユーザかどうか
      rd.setLoginuser(record.getUserId().intValue() == userid);
      // オーナーかどうか
      rd.setOwner(record.getOwnerId().intValue() == userid);
      // 共有メンバーかどうか
      rd.setMember(is_member);
      // 繰り返しパターン
      rd.setPattern(record.getRepeatPattern());

      // ユーザもしくは設備のコンテナを取得する.
      ScheduleOnedayContainer con = null;
      if (ScheduleUtils.SCHEDULEMAP_TYPE_USER.equals(record.getType())) {
        con = map.get(record.getUserId());
      } else {
        // if (ScheduleUtils.SCHEDULEMAP_TYPE_FACILITY.equals(record.getType()))
        // の場合
        con = facilitymap.get(record.getUserId());
      }

      // 期間スケジュールの場合
      if (rd.getPattern().equals("S")) {
        is_hasspan = true;
        List<ScheduleOnedayResultData> terms = termmap.get(record.getUserId());
        if (terms != null) {
          // 期間スケジュールを格納
          terms.add(rd);
        }

        return rd;
      }

      if (!rd.getPattern().equals("N")) {
        // 繰り返しスケジュール
        if (!ScheduleUtils.isView(
            getViewDate(),
            rd.getPattern(),
            rd.getStartDate().getValue(),
            rd.getEndDate().getValue())) {
          return rd;
        }
        rd.setRepeat(true);
      }
      con.addResultData(rd, startHour, endHour, getViewDate());
    } catch (Exception e) {
      logger.error("schedule", e);
      return null;
    }
    return rd;
  }

  /**
   * @param action
   * @param rundata
   * @param context
   * @return
   */
  @Override
  public boolean doViewList(ALAction action, RunData rundata, Context context) {
    boolean res = super.doViewList(action, rundata, context);
    // 後処理
    postDoList();
    return res;
  }

  /**
   * @param action
   * @param rundata
   * @param context
   * @return
   */
  @Override
  public boolean doSelectList(ALAction action, RunData rundata, Context context) {
    boolean res = super.doSelectList(action, rundata, context);
    // 後処理
    postDoList();
    return res;
  }

  /**
   * スケジュールの一日コンテナの各rows値の中で、最大値を取得します。
   *
   * @param list
   */
  private int[] getMaxRowsFromContainer(Collection<ScheduleOnedayContainer> list) {

    int nowRows[] = new int[rows.length];
    for (ScheduleOnedayContainer container : list) {
      container.last(startHour, endHour, getViewDate());
      if (container.isDuplicate()) {
        is_duplicate = true;
      }

      int size = rows.length;
      int[] tmpRows = container.getRows();
      for (int i = 0; i < size; i++) {
        if (tmpRows[i] > nowRows[i]) {
          nowRows[i] = tmpRows[i];
        }
      }
    }
    return nowRows;
  }

  /** 検索後の処理を行います。 */
  private void postDoList() {
    int userRows[] = getMaxRowsFromContainer(map.values());

    int facilityRows[] = getMaxRowsFromContainer(facilitymap.values());

    int size = rows.length;
    for (int i = 0; i < size; i++) {
      rows[i] = Math.max(rows[i], Math.max(userRows[i], facilityRows[i]));
      max += rows[i];
    }
  }

  @Override
  public void loadToDo(RunData rundata, Context context) {
    try {
      SelectQuery<EipTTodo> query = getSelectQueryForTodo(rundata, context);
      List<EipTTodo> todos = query.fetchList();

      int todossize = todos.size();
      for (int i = 0; i < todossize; i++) {
        EipTTodo record = todos.get(i);
        ScheduleToDoResultData rd = new ScheduleToDoResultData();
        rd.initField();

        // ポートレット ToDo のへのリンクを取得する.
        String todo_url = "";
        if (userid == record.getTurbineUser().getUserId().intValue()) {
          todo_url =
              ScheduleUtils.getPortletURItoTodoDetailPane(
                  rundata, "ToDo", record.getTodoId().longValue(), portletId);
        } else {
          todo_url =
              ScheduleUtils.getPortletURItoTodoPublicDetailPane(
                  rundata, "ToDo", record.getTodoId().longValue(), portletId);
        }
        rd.setTodoId(record.getTodoId().intValue());
        rd.setTodoName(record.getTodoName());
        rd.setUserId(record.getTurbineUser().getUserId().intValue());
        rd.setStartDate(record.getStartDate());
        rd.setEndDate(record.getEndDate());
        rd.setTodoUrl(todo_url);
        // 公開/非公開を設定する.
        rd.setPublicFlag("T".equals(record.getPublicFlag()));

        List<ScheduleToDoResultData> usertodos1 = todomap.get(record.getTurbineUser().getUserId());
        if (usertodos1 != null) {
          // ToDo を格納
          usertodos1.add(rd);
        }
      }
    } catch (Exception ex) {
      logger.error("schedule", ex);
      return;
    }
  }

  private SelectQuery<EipTTodo> getSelectQueryForTodo(RunData rundata, Context context) {
    Integer uid = Integer.valueOf(userid);

    SelectQuery<EipTTodo> query = Database.query(EipTTodo.class);
    Expression exp1 =
        ExpressionFactory.noMatchExp(EipTTodo.STATE_PROPERTY, Short.valueOf((short) 100));
    query.setQualifier(exp1);

    Expression exp01 = ExpressionFactory.matchDbExp(TurbineUser.USER_ID_PK_COLUMN, uid);
    Expression exp02 = ExpressionFactory.noMatchDbExp(TurbineUser.USER_ID_PK_COLUMN, uid);
    Expression exp03 = ExpressionFactory.matchExp(EipTTodo.PUBLIC_FLAG_PROPERTY, "T");
    Expression exp04 = ExpressionFactory.matchExp(EipTTodo.ADDON_SCHEDULE_FLG_PROPERTY, "T");
    query.andQualifier(exp01.orExp(exp02.andExp(exp03)).andExp(exp04));

    // 終了日時
    Expression exp11 =
        ExpressionFactory.greaterOrEqualExp(EipTTodo.END_DATE_PROPERTY, getViewDate().getValue());
    // 開始日時
    Expression exp12 =
        ExpressionFactory.lessOrEqualExp(EipTTodo.START_DATE_PROPERTY, getViewDate().getValue());

    // 開始日時のみ指定されている ToDo を検索
    Expression exp21 =
        ExpressionFactory.lessOrEqualExp(EipTTodo.START_DATE_PROPERTY, getViewDate().getValue());
    Expression exp22 =
        ExpressionFactory.matchExp(EipTTodo.END_DATE_PROPERTY, ToDoUtils.getEmptyDate());

    // 終了日時のみ指定されている ToDo を検索
    Expression exp31 =
        ExpressionFactory.greaterOrEqualExp(EipTTodo.END_DATE_PROPERTY, getViewDate().getValue());
    Expression exp32 =
        ExpressionFactory.matchExp(EipTTodo.START_DATE_PROPERTY, ToDoUtils.getEmptyDate());

    query.andQualifier((exp11.andExp(exp12)).orExp(exp21.andExp(exp22)).orExp(exp31.andExp(exp32)));
    return query;
  }

  /*
   *
   */
  @Override
  protected Attributes getColumnMap() {
    Attributes map = new Attributes();
    map.putValue("group", VEipTScheduleList.USER_ID_PROPERTY);
    return map;
  }

  /**
   * 指定した時間のcolspanを取得します。
   *
   * @param hour
   * @return
   */
  public int getColspan(int hour) {
    return rows[(hour - startHour) * 12]
        + rows[(hour - startHour) * 12 + 1]
        + rows[(hour - startHour) * 12 + 2]
        + rows[(hour - startHour) * 12 + 3]
        + rows[(hour - startHour) * 12 + 4]
        + rows[(hour - startHour) * 12 + 5]
        + rows[(hour - startHour) * 12 + 6]
        + rows[(hour - startHour) * 12 + 7]
        + rows[(hour - startHour) * 12 + 8]
        + rows[(hour - startHour) * 12 + 9]
        + rows[(hour - startHour) * 12 + 10]
        + rows[(hour - startHour) * 12 + 11];
  }

  /**
   * 指定したスケジュールのcolspanを取得します。
   *
   * @param hour
   * @return
   */
  public int getScheduleColspan(ScheduleOnedayResultData rd, int[] rows_) {
    int st = rd.getStartRow();
    int ed = rd.getEndRow();
    int span = 0;
    if (st == ed) {
      if (rows_[st] == rd.getIndex()) {
        span = rows[st] - rows_[st] + 1;
      } else {
        span = 1;
      }
    } else {
      for (int i = st; i < ed; i++) {
        span += rows[i];
      }
      span += 1 - rows_[st];
    }
    return span;
  }

  /**
   * 期間スケジュールを取得します。
   *
   * @param id
   * @return
   */
  public ScheduleOnedayResultData getSpanSchedule(long id) {
    Integer userid = Integer.valueOf((int) id);
    return map.get(userid).getSpanResultData();
  }

  /**
   * 指定したユーザーのスケジュールリストを取得します。
   *
   * @param id
   * @return
   */
  public List<ScheduleOnedayResultData> getScheduleList(long id) {
    Integer userid = Integer.valueOf((int) id);
    return map.get(userid).getSchedule();
  }

  /**
   * 指定したユーザーのrowsを取得します。
   *
   * @param id
   * @return
   */
  public int[] getRows(long id) {
    Integer userid = Integer.valueOf((int) id);
    return map.get(userid).getRows();
  }

  public List<ScheduleOnedayResultData> getDuplicateSchedule(long id) {
    Integer userid = Integer.valueOf((int) id);
    return map.get(userid).getDuplicateSchedule();
  }

  /**
   * 指定したユーザーの重複スケジュールリストを取得します。
   *
   * @param id
   * @return
   */
  public List<ScheduleOnedayResultData> getDuplicateScheduleList(long id) {
    Integer userid = Integer.valueOf((int) id);
    return map.get(userid).getDuplicateSchedule();
  }

  public int getDuplicateScheduleListRowCount(long id) {
    Integer userid = Integer.valueOf((int) id);
    return map.get(userid).getDuplicateScheduleRowCount();
  }

  /**
   * 部署マップを取得します。
   *
   * @return
   */
  public Map<Integer, ALEipPost> getPostMap() {
    return ALEipManager.getInstance().getPostMap();
  }

  /**
   * 共有メンバーを取得します。
   *
   * @return
   */
  public List<ALEipUser> getMemberList() {
    return members;
  }

  /**
   * グループリストを取得します。
   *
   * @return
   */
  public List<ALEipGroup> getGroupList() {
    return groups;
  }

  /**
   * 施設のグループリストを取得します。
   *
   * @return
   */
  public List<ALEipGroup> getFacilitiyGroupList() {
    return facilitiyGroups;
  }

  /**
   * 指定したユーザーが自ユーザーかどうかを返します。
   *
   * @param id
   * @return
   */
  public boolean isMatch(long id) {
    return userid == (int) id;
  }

  /**
   * colspanの最大値を返します。
   *
   * @return
   */
  public int getMax() {
    return max - 1;
  }

  /**
   * 期間スケジュールがあるかどうかを返します。
   *
   * @return
   */
  public boolean isHasspan() {
    return is_hasspan;
  }

  /**
   * ポートレット MyGroup へのリンクを取得する.
   *
   * @return
   */
  public String getMyGroupURI() {
    return myGroupURI;
  }

  /**
   * 期間スケジュールリストを取得する.
   *
   * @param id
   * @return
   */
  public List<ScheduleOnedayResultData> getTermResultDataList(long id) {
    return termmap.get(Integer.valueOf((int) id));
  }

  /**
   * ToDo リストを取得する.
   *
   * @param id
   * @return
   */
  public List<ScheduleToDoResultData> getToDoResultDataList(long id) {
    return todomap.get(Integer.valueOf((int) id));
  }

  @Override
  public void setPortletId(String id) {
    portletId = id;
  }

  public List<FacilityResultData> getFacilityList() {
    return facilityList;
  }

  /**
   * 指定した施設のスケジュールリストを取得します。
   *
   * @param id
   * @return
   */
  public List<ScheduleOnedayResultData> getFacilityScheduleList(long id) {
    Integer fid = Integer.valueOf((int) id);
    return facilitymap.get(fid).getSchedule();
  }

  @Override
  public String getViewDateText() {
    return ALLocalizationUtils.getl10nFormat(
        "SCHEDULE_DATE_FORMAT_NOSPACE",
        getViewDate().getYear(),
        getViewDate().getMonth(),
        getViewDate().getDay());
  }

  /**
   * 指定した設備のrowsを取得します。
   *
   * @param id
   * @return
   */
  public int[] getFacilityRows(long id) {
    Integer fid = Integer.valueOf((int) id);
    return facilitymap.get(fid).getRows();
  }

  /**
   * 指定した設備の重複スケジュールリストを取得します。
   *
   * @param id
   * @return
   */
  public List<ScheduleOnedayResultData> getFacilityDuplicateScheduleList(long id) {
    Integer fid = Integer.valueOf((int) id);
    return facilitymap.get(fid).getDuplicateSchedule();
  }

  public int getFacilityDuplicateScheduleListRowCount(long id) {
    Integer fid = Integer.valueOf((int) id);
    return facilitymap.get(fid).getDuplicateScheduleRowCount();
  }

  /**
   * アクセス権限チェック用メソッド。<br>
   * アクセス権限の機能名を返します。
   *
   * @return
   */
  @Override
  public String getAclPortletFeature() {
    return ALAccessControlConstants.POERTLET_FEATURE_SCHEDULE_SELF;
  }

  @Override
  public boolean hasAuthoritySelfInsert() {
    return hasAuthoritySelfInsert;
  }

  public boolean hasAuthorityFacilityInsert() {
    return hasAuthorityFacilityInsert;
  }

  private TurbineGroup getGroup(String filter) {
    Expression exp1 = ExpressionFactory.matchExp(TurbineGroup.GROUP_NAME_PROPERTY, filter);

    SelectQuery<TurbineGroup> query = Database.query(TurbineGroup.class);

    query.setQualifier(exp1);
    List<TurbineGroup> list = query.fetchList();
    if (list.isEmpty()) {
      return null;
    }
    return list.get(0);
  }

  public TurbineGroup getTargetGroupName() {
    return target_group_name;
  }
}
コード例 #26
0
ファイル: NoteClientSelectData.java プロジェクト: ntamvl/aipo
/** 伝言メモ依頼者検索データを管理するためのクラスです。 */
public class NoteClientSelectData extends ALAbstractSelectData<EipTNoteMap, EipTNoteMap>
    implements ALData {

  /** logger */
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(NoteClientSelectData.class.getName());

  /** ポートレットにアクセスしているユーザ ID */
  private String userId;

  /** 新着数 */
  private int newNoteAllSum = 0;

  /** 受信未読数 */
  private int unreadReceivedNotesAllSum = 0;

  /**
   * @param action
   * @param rundata
   * @param context
   * @throws ALPageNotFoundException
   * @throws ALDBErrorException
   */
  @Override
  public void init(ALAction action, RunData rundata, Context context)
      throws ALPageNotFoundException, ALDBErrorException {

    String sort = ALEipUtils.getTemp(rundata, context, LIST_SORT_STR);
    if (sort == null || sort.equals("")) {
      ALEipUtils.setTemp(
          rundata,
          context,
          LIST_SORT_STR,
          ALEipUtils.getPortlet(rundata, context).getPortletConfig().getInitParameter("p2a-sort"));
      logger.debug(
          "Init Parameter (Note) : "
              + ALEipUtils.getPortlet(rundata, context)
                  .getPortletConfig()
                  .getInitParameter("p2a-sort"));
    }

    super.init(action, rundata, context);
  }

  /**
   * @param rundata
   * @param context
   * @return
   */
  @Override
  protected ResultList<EipTNoteMap> selectList(RunData rundata, Context context) {

    try {
      userId = Integer.toString(ALEipUtils.getUserId(rundata));
      newNoteAllSum = NoteUtils.getNewReceivedNoteAllSum(rundata, userId);
      unreadReceivedNotesAllSum = NoteUtils.getUnreadReceivedNotesAllSum(rundata, userId);

      SelectQuery<EipTNoteMap> query = getSelectQuery(rundata, context);
      buildSelectQueryForListView(query);
      buildSelectQueryForListViewSort(query, rundata, context);

      return query.getResultList();
    } catch (Exception ex) {
      logger.error("note", ex);
      return null;
    }
  }

  /**
   * ソート用の <code>SelectQuery</code> を構築します。
   *
   * @param crt
   * @return
   */
  @Override
  protected SelectQuery<EipTNoteMap> buildSelectQueryForListViewSort(
      SelectQuery<EipTNoteMap> query, RunData rundata, Context context) {
    String sort = "create_date";
    String sort_type = ALEipConstants.LIST_SORT_TYPE_DESC;
    String crt_key = null;

    Attributes map = getColumnMap();

    crt_key = map.getValue(sort);
    if (crt_key == null) {
      return query;
    }
    query.orderDesending(crt_key);
    current_sort = sort;
    current_sort_type = sort_type;
    return query;
  }

  /**
   * @param rundata
   * @param context
   * @return
   */
  @Override
  protected EipTNoteMap selectDetail(RunData rundata, Context context) {
    return null;
  }

  /**
   * @param map
   * @return
   */
  @Override
  protected Object getResultData(EipTNoteMap map) {
    try {
      EipTNote record = map.getEipTNote();

      NoteClientResultData rd = new NoteClientResultData();
      rd.initField();
      rd.setNoteId(record.getNoteId().intValue());
      rd.setClientName(ALCommonUtils.compressString(record.getClientName(), getStrLength()));
      rd.setCompanyName(ALCommonUtils.compressString(record.getCompanyName(), getStrLength()));
      rd.setNoteStat(map.getNoteStat());
      rd.setAcceptDate(record.getAcceptDate());

      String subject = "";
      if (record.getSubjectType().equals("0")) {
        subject = ALCommonUtils.compressString(record.getCustomSubject(), getStrLength());
      } else if (record.getSubjectType().equals("1")) {
        subject = ALLocalizationUtils.getl10n("NOTE_CALL_AGAIN_NO_PERIOD");
      } else if (record.getSubjectType().equals("2")) {
        subject = ALLocalizationUtils.getl10n("NOTE_MAIL_CALL_BACK");
      } else if (record.getSubjectType().equals("3")) {
        subject = ALLocalizationUtils.getl10n("NOTE_MAIL_TELL_ME");
      } else if (record.getSubjectType().equals("4")) {
        subject = ALLocalizationUtils.getl10n("NOTE_MAIL_TAKE_A_MESSAGE");
      }

      rd.setSubject(subject);

      if (NoteUtils.NOTE_STAT_NEW.equals(map.getNoteStat())) {
        rd.setNoteStat(NoteUtils.NOTE_STAT_NEW);
        rd.setNoteStatImage("images/note/note_new_message.gif");
        rd.setNoteStatImageDescription(ALLocalizationUtils.getl10n("NOTE_NEW_MESSAGE"));
      } else if (NoteUtils.NOTE_STAT_UNREAD.equals(map.getNoteStat())) {
        rd.setNoteStat(NoteUtils.NOTE_STAT_UNREAD);
        rd.setNoteStatImage("images/note/note_unread_message.gif");
        rd.setNoteStatImageDescription(ALLocalizationUtils.getl10n("NOTE_UNREAD_MESSAGE"));
      } else {
        rd.setNoteStat(NoteUtils.NOTE_STAT_READ);
        rd.setNoteStatImage("images/note/note_read_message.gif");
        rd.setNoteStatImageDescription(ALLocalizationUtils.getl10n("NOTE_READ_MESSAGE"));
      }

      ALEipUser user = ALEipUtils.getALEipUser(Integer.valueOf(record.getOwnerId()).intValue());
      rd.setSrcUserId(record.getOwnerId());
      rd.setSrcUserFullName(user.getAliasName().getValue());

      return rd;
    } catch (RuntimeException e) {
      logger.error("note", e);
      return null;
    } catch (Exception ex) {
      logger.error("note", ex);
      return null;
    }
  }

  /**
   * @param obj
   * @return
   */
  @Override
  protected Object getResultDataDetail(EipTNoteMap obj) {
    return null;
  }

  /** @return */
  @Override
  protected Attributes getColumnMap() {
    Attributes map = new Attributes();
    map.putValue(
        "client_name", EipTNoteMap.EIP_TNOTE_PROPERTY + "." + EipTNote.CLIENT_NAME_PROPERTY);
    map.putValue(
        "subject_type", EipTNoteMap.EIP_TNOTE_PROPERTY + "." + EipTNote.SUBJECT_TYPE_PROPERTY);
    map.putValue(
        "create_date", EipTNoteMap.EIP_TNOTE_PROPERTY + "." + EipTNote.CREATE_DATE_PROPERTY);
    map.putValue(
        "accept_date", EipTNoteMap.EIP_TNOTE_PROPERTY + "." + EipTNote.ACCEPT_DATE_PROPERTY);
    map.putValue("note_stat", EipTNoteMap.NOTE_STAT_PROPERTY);
    return map;
  }

  /**
   * 検索条件を設定した Criteria を返す.
   *
   * @param rundata
   * @return
   */
  private SelectQuery<EipTNoteMap> getSelectQuery(RunData rundata, Context context) {
    return NoteUtils.getSelectQueryNoteList(rundata, context);
  }

  /** @return */
  public String getUserId() {
    return userId;
  }

  /**
   * @param userId
   * @return
   */
  public String getUserName(String userId) {
    return NoteUtils.getUserName(userId);
  }

  /**
   * @param userId
   * @return
   */
  public String getUserFullName(String userId) {
    try {
      ALEipUser user = ALEipUtils.getALEipUser(Integer.valueOf(userId).intValue());
      return user.getAliasName().getValue();
    } catch (Exception e) {
      return "";
    }
  }

  /**
   * @param userName
   * @return
   */
  public String getUserId(String userName) {
    return NoteUtils.getUserId(userName);
  }

  /** @return */
  public int getNewNoteAllSum() {
    return newNoteAllSum;
  }

  /** @return */
  public int getUnreadReceivedNotesAllSum() {
    return unreadReceivedNotesAllSum;
  }
}
コード例 #27
0
/** 共有カテゴリ検索データを管理するクラスです。 <br> */
public class CommonCategorySelectData
    extends ALAbstractSelectData<EipTCommonCategory, EipTCommonCategory> implements ALData {

  /** logger */
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(CommonCategorySelectData.class.getName());

  /** ログインユーザ ID */
  private int uid;

  /** 他人の共有カテゴリ編集権限 */
  private boolean authority_edit;

  /** 他人の共有カテゴリ削除権限 */
  private boolean authority_delete;

  /** 他人の共有カテゴリ一覧表示権限 */
  private boolean authority_list;

  /** 他人の共有カテゴリ詳細表示権限 */
  private boolean authority_detail;

  /**
   * @param action
   * @param rundata
   * @param context
   * @throws ALPageNotFoundException
   * @throws ALDBErrorException
   */
  @Override
  public void init(ALAction action, RunData rundata, Context context)
      throws ALPageNotFoundException, ALDBErrorException {

    uid = ALEipUtils.getUserId(rundata);

    authority_list =
        CommonCategoryUtils.checkPermission(
            rundata,
            context,
            ALAccessControlConstants.VALUE_ACL_LIST,
            ALAccessControlConstants.POERTLET_FEATURE_MANHOUR_COMMON_CATEGORY_OTHER);

    authority_detail =
        CommonCategoryUtils.checkPermission(
            rundata,
            context,
            ALAccessControlConstants.VALUE_ACL_DETAIL,
            ALAccessControlConstants.POERTLET_FEATURE_MANHOUR_COMMON_CATEGORY_OTHER);

    authority_edit =
        CommonCategoryUtils.checkPermission(
            rundata,
            context,
            ALAccessControlConstants.VALUE_ACL_UPDATE,
            ALAccessControlConstants.POERTLET_FEATURE_MANHOUR_COMMON_CATEGORY_OTHER);

    authority_delete =
        CommonCategoryUtils.checkPermission(
            rundata,
            context,
            ALAccessControlConstants.VALUE_ACL_DELETE,
            ALAccessControlConstants.POERTLET_FEATURE_MANHOUR_COMMON_CATEGORY_OTHER);

    super.init(action, rundata, context);
  }

  /**
   * 一覧データを取得します。 <br>
   *
   * @param rundata
   * @param context
   * @return
   */
  @Override
  protected ResultList<EipTCommonCategory> selectList(RunData rundata, Context context) {
    try {

      SelectQuery<EipTCommonCategory> query = getSelectQuery(rundata, context);
      buildSelectQueryForListView(query);
      buildSelectQueryForListViewSort(query, rundata, context);

      return query.getResultList();
    } catch (Exception ex) {
      logger.error("CommonCategorySelectData.selectList", ex);
      return null;
    }
  }

  /**
   * 検索条件を設定した SelectQuery を返します。 <br>
   *
   * @param rundata
   * @param context
   * @return
   */
  private SelectQuery<EipTCommonCategory> getSelectQuery(RunData rundata, Context context) {
    SelectQuery<EipTCommonCategory> query = Database.query(EipTCommonCategory.class);

    Expression exp =
        ExpressionFactory.noMatchDbExp(
            EipTCommonCategory.COMMON_CATEGORY_ID_PK_COLUMN, Integer.valueOf(1));
    query.setQualifier(exp);

    if (!authority_list) {
      Expression exp2 =
          ExpressionFactory.matchExp(
              EipTCommonCategory.CREATE_USER_ID_PROPERTY, Integer.valueOf(uid));
      query.andQualifier(exp2);
    }

    return query;
  }

  /**
   * 詳細データを取得します。 <br>
   *
   * @param rundata
   * @param context
   * @return
   */
  @Override
  protected EipTCommonCategory selectDetail(RunData rundata, Context context) {
    // オブジェクトモデルを取得
    return CommonCategoryUtils.getEipTCommonCategory(rundata, context);
  }

  /**
   * ResultDataを取得します。(一覧データ) <br>
   *
   * @param obj
   * @return
   */
  @Override
  protected Object getResultData(EipTCommonCategory obj) {
    EipTCommonCategory record = obj;
    CommonCategoryResultData rd = new CommonCategoryResultData();
    rd.initField();
    rd.setCommonCategoryId(record.getCommonCategoryId().longValue());
    rd.setName(ALCommonUtils.compressString(record.getName(), getStrLength()));
    rd.setCreateUserId(record.getCreateUserId().longValue());
    return rd;
  }

  /**
   * ResultDataを取得します。(詳細データ) <br>
   *
   * @param obj
   * @return
   */
  @Override
  protected Object getResultDataDetail(EipTCommonCategory obj) {
    EipTCommonCategory record = obj;
    CommonCategoryResultData rd = new CommonCategoryResultData();
    rd.initField();
    rd.setCommonCategoryId(record.getCommonCategoryId().longValue());
    rd.setName(record.getName());
    rd.setNote(record.getNote());
    rd.setCreateUserId(record.getCreateUserId().intValue());
    rd.setCreateDate(ALDateUtil.format(record.getCreateDate(), "yyyy年M月d日"));
    rd.setUpdateDate(ALDateUtil.format(record.getUpdateDate(), "yyyy年M月d日"));
    return rd;
  }

  /** @return */
  @Override
  protected Attributes getColumnMap() {
    Attributes map = new Attributes();
    map.putValue("name", EipTCommonCategory.NAME_PROPERTY);
    return map;
  }

  /**
   * ログインユーザID
   *
   * @return
   */
  public int getUserId() {
    return uid;
  }

  /**
   * @param id
   * @return
   */
  public boolean isMatch(int id1, long id2) {
    return id1 == (int) id2;
  }

  public boolean getAuthorityEdit() {
    return authority_edit;
  }

  public boolean getAuthorityDelete() {
    return authority_delete;
  }

  public boolean getAuthorityList() {
    return authority_list;
  }

  public boolean getAuthorityDetail() {
    return authority_detail;
  }

  /**
   * アクセス権限チェック用メソッド。<br>
   * アクセス権限の機能名を返します。
   *
   * @return
   */
  @Override
  public String getAclPortletFeature() {
    return ALAccessControlConstants.POERTLET_FEATURE_MANHOUR_COMMON_CATEGORY;
  }
}
コード例 #28
0
ファイル: TimelineScreen.java プロジェクト: reskohz/aipo
/** タイムライントピックの一覧を処理するクラスです。 */
public class TimelineScreen extends ALVelocityScreen {

  /** logger */
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(TimelineScreen.class.getName());

  /**
   * @param rundata
   * @param context
   * @throws Exception
   */
  @Override
  protected void doOutput(RunData rundata, Context context) throws Exception {

    // VelocityPortlet portlet = ALEipUtils.getPortlet(rundata, context);
    // String mode = rundata.getParameters().getString(ALEipConstants.MODE);
    try {
      int rows = 20;
      int scrollTop = 0;
      if (rundata.getParameters().containsKey("rows")) {
        rows = rundata.getParameters().getInt("rows");
      }
      if (rundata.getParameters().containsKey("scrollTop")) {
        scrollTop = rundata.getParameters().getInt("scrollTop");
      }
      if (rundata.getUserAgent().trim().indexOf("Mac") != -1) {
        context.put("isMacOS", "true");
      }

      ParameterParser parser = rundata.getParameters();

      ALEipUtils.passPSML(
          rundata, context, "p3a-group", parser.getString(TimelineUtils.TARGET_GROUP_NAME));
      ALEipUtils.passPSML(
          rundata, context, "p4a-group", parser.getString(TimelineUtils.TARGET_DISPLAY_NAME));

      TimelineSelectData listData = new TimelineSelectData();
      listData.initField();
      listData.setContentHeightMax(
          Integer.parseInt(
              ALEipUtils.getPortlet(rundata, context)
                  .getPortletConfig()
                  .getInitParameter("p1a-rows", "0")));
      listData.setRowsNum(rows);
      listData.setScrollTop(scrollTop);
      listData.doViewList(this, rundata, context);

      String layout_template = "portlets/html/ajax-timeline.vm";
      setTemplate(rundata, context, layout_template);

    } catch (Exception ex) {
      logger.error("[TimelineScreen] Exception.", ex);
      ALEipUtils.redirectDBError(rundata);
    }
  }

  /** @return */
  @Override
  protected String getPortletName() {
    return TimelineUtils.TIMELIME_PORTLET_NAME;
  }
}
コード例 #29
0
ファイル: ToDoFormJSONScreen.java プロジェクト: reskohz/aipo
/** ToDoをJSONデータとして出力するクラスです。 <br> */
public class ToDoFormJSONScreen extends ALJSONScreen {

  /** logger */
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(ToDoFormJSONScreen.class.getName());

  @Override
  protected String getJSONString(RunData rundata, Context context) throws Exception {
    String result = new JSONArray().toString();
    String mode = this.getMode();
    try {

      if (ALEipConstants.MODE_INSERT.equals(mode)) {
        //
        ToDoFormData formData = new ToDoFormData();
        formData.initField();
        formData.loadCategoryList(rundata);
        if (formData.doInsert(this, rundata, context)) {
        } else {
          JSONArray json = JSONArray.fromObject(context.get(ALEipConstants.ERROR_MESSAGE_LIST));
          result = json.toString();
        }

      } else if (ALEipConstants.MODE_UPDATE.equals(mode)) {

        ToDoFormData formData = new ToDoFormData();
        formData.initField();
        formData.loadCategoryList(rundata);
        if (formData.doUpdate(this, rundata, context)) {
        } else {
          JSONArray json = JSONArray.fromObject(context.get(ALEipConstants.ERROR_MESSAGE_LIST));
          result = json.toString();
        }
      } else if (ALEipConstants.MODE_DELETE.equals(mode)) {

        ToDoFormData formData = new ToDoFormData();
        formData.initField();
        formData.loadCategoryList(rundata);
        if (formData.doDelete(this, rundata, context)) {
        } else {
          JSONArray json = JSONArray.fromObject(context.get(ALEipConstants.ERROR_MESSAGE_LIST));
          result = json.toString();
        }
      } else if ("multi_delete".equals(mode)) {

        ToDoMultiDelete delete = new ToDoMultiDelete();
        if (delete.doMultiAction(this, rundata, context)) {
        } else {
          JSONArray json = JSONArray.fromObject(context.get(ALEipConstants.ERROR_MESSAGE_LIST));
          result = json.toString();
        }
      } else if ("multi_complete".equals(mode)) {

        ToDoMultiStateUpdate delete = new ToDoMultiStateUpdate();
        if (delete.doMultiAction(this, rundata, context)) {
        } else {
          JSONArray json = JSONArray.fromObject(context.get(ALEipConstants.ERROR_MESSAGE_LIST));
          result = json.toString();
        }
      }
    } catch (Exception e) {
      logger.error("[ToDoFormJSONScreen]", e);
    }

    return result;
  }
}
コード例 #30
0
/** アドレス帳での検索BOX用データです。(社内アドレス検索用) */
public class AddressBookCorpWordSelectData
    extends AbstractAddressBookWordSelectData<TurbineUser, TurbineUser> {

  /** フィルタに利用するグループリスト */
  private List<AddressBookGroupResultData> groupList;

  /** マイグループリスト */
  private List<ALEipGroup> myGroupList = null;

  /** logger */
  private static final JetspeedLogger logger =
      JetspeedLogFactoryService.getLogger(AddressBookWordSelectData.class.getName());

  /**
   * @param action
   * @param rundata
   * @param context
   * @throws ALPageNotFoundException
   * @throws ALDBErrorException
   */
  @Override
  public void init(ALAction action, RunData rundata, Context context)
      throws ALPageNotFoundException, ALDBErrorException {
    super.init(action, rundata, context);
  }

  /**
   * 自分がオーナーのアドレスを取得
   *
   * @param rundata
   * @param context
   * @return
   */
  @Override
  protected ResultList<TurbineUser> selectList(RunData rundata, Context context) {
    ResultList<TurbineUser> list;
    try {
      SelectQuery<TurbineUser> query = getSelectQuery(rundata, context);
      buildSelectQueryForListView(query);
      buildSelectQueryForListViewSort(query, rundata, context);
      list = query.getResultList();
    } catch (Exception ex) {
      logger.error("AddressBookCorpWordSelectData.selectList", ex);
      return null;
    }
    return list;
  }

  /**
   * @param rundata
   * @param context
   * @return
   */
  @Override
  protected TurbineUser selectDetail(RunData rundata, Context context) {
    return null;
  }

  /**
   * @param obj
   * @return
   */
  @Override
  protected Object getResultData(TurbineUser obj) {
    try {
      return AddressBookUtils.getCorpResultData(obj, getStrLength());
    } catch (Exception ex) {
      logger.error("AddressBookCorpWordSelectData.getResultData", ex);
      return null;
    }
  }

  /**
   * @param obj
   * @return
   */
  @Override
  protected Object getResultDataDetail(TurbineUser obj) {
    return null;
  }

  /** @return */
  @Override
  protected Attributes getColumnMap() {
    Attributes map = new Attributes();

    map.putValue(
        "corp_group",
        TurbineUser.TURBINE_USER_GROUP_ROLE_PROPERTY
            + "."
            + TurbineUserGroupRole.TURBINE_GROUP_PROPERTY
            + "."
            + TurbineGroup.GROUP_NAME_COLUMN);
    map.putValue("name_kana", TurbineUser.LAST_NAME_KANA_PROPERTY);

    return map;
  }

  /**
   * @param rundata
   * @param context
   * @return
   */
  private SelectQuery<TurbineUser> getSelectQuery(RunData rundata, Context context) {
    SelectQuery<TurbineUser> query = null;
    String word = searchWord.getValue();
    String transWord =
        ALStringUtil.convertHiragana2Katakana(ALStringUtil.convertH2ZKana(searchWord.getValue()));

    query = Database.query(TurbineUser.class);

    Expression exp_exclude_my_group =
        ExpressionFactory.matchExp(
            TurbineUser.TURBINE_USER_GROUP_ROLE_PROPERTY
                + "."
                + TurbineUserGroupRole.TURBINE_GROUP_PROPERTY
                + "."
                + TurbineGroup.OWNER_ID_PROPERTY,
            1);

    Expression exp01 = ExpressionFactory.matchExp(TurbineUser.DISABLED_PROPERTY, "F");
    query.setQualifier(exp01);

    Expression exp02 =
        ExpressionFactory.noMatchDbExp(TurbineUser.USER_ID_PK_COLUMN, Integer.valueOf(1));
    Expression exp03 =
        ExpressionFactory.noMatchDbExp(TurbineUser.USER_ID_PK_COLUMN, Integer.valueOf(2));
    Expression exp04 =
        ExpressionFactory.noMatchDbExp(TurbineUser.USER_ID_PK_COLUMN, Integer.valueOf(3));
    query.andQualifier(exp02.andExp(exp03).andExp(exp04));

    Expression exp11 = ExpressionFactory.likeExp(TurbineUser.FIRST_NAME_PROPERTY, "%" + word + "%");
    Expression exp12 = ExpressionFactory.likeExp(TurbineUser.LAST_NAME_PROPERTY, "%" + word + "%");
    Expression exp13 =
        ExpressionFactory.likeExp(TurbineUser.FIRST_NAME_KANA_PROPERTY, "%" + word + "%");
    Expression exp14 =
        ExpressionFactory.likeExp(TurbineUser.LAST_NAME_KANA_PROPERTY, "%" + word + "%");
    Expression exp15 = ExpressionFactory.likeExp(TurbineUser.EMAIL_PROPERTY, "%" + word + "%");
    Expression exp16 =
        ExpressionFactory.likeExp(
            TurbineUser.TURBINE_USER_GROUP_ROLE_PROPERTY
                + "."
                + TurbineUserGroupRole.TURBINE_GROUP_PROPERTY
                + "."
                + TurbineGroup.GROUP_ALIAS_NAME_PROPERTY,
            "%" + word + "%");
    exp16 = exp16.andExp(exp_exclude_my_group);
    Expression exp21 =
        ExpressionFactory.likeExp(TurbineUser.OUT_TELEPHONE_PROPERTY, "%" + word + "%");
    Expression exp22 =
        ExpressionFactory.likeExp(TurbineUser.IN_TELEPHONE_PROPERTY, "%" + word + "%");
    Expression exp23 =
        ExpressionFactory.likeExp(TurbineUser.CELLULAR_PHONE_PROPERTY, "%" + word + "%");

    Expression exp31 =
        ExpressionFactory.likeExp(TurbineUser.FIRST_NAME_PROPERTY, "%" + transWord + "%");
    Expression exp32 =
        ExpressionFactory.likeExp(TurbineUser.LAST_NAME_PROPERTY, "%" + transWord + "%");
    Expression exp33 =
        ExpressionFactory.likeExp(TurbineUser.FIRST_NAME_KANA_PROPERTY, "%" + transWord + "%");
    Expression exp34 =
        ExpressionFactory.likeExp(TurbineUser.LAST_NAME_KANA_PROPERTY, "%" + transWord + "%");
    Expression exp35 =
        ExpressionFactory.likeExp(
            TurbineUser.TURBINE_USER_GROUP_ROLE_PROPERTY
                + "."
                + TurbineUserGroupRole.TURBINE_GROUP_PROPERTY
                + "."
                + TurbineGroup.GROUP_ALIAS_NAME_PROPERTY,
            "%" + transWord + "%");
    exp35 = exp35.andExp(exp_exclude_my_group);
    Expression exp36 = ExpressionFactory.likeExp(TurbineUser.CODE_PROPERTY, "%" + transWord + "%");
    if (word != null && !"".equals(word)) {
      query.andQualifier(
          exp11
              .orExp(exp12)
              .orExp(exp13)
              .orExp(exp14)
              .orExp(exp15)
              .orExp(exp16)
              .orExp(exp21)
              .orExp(exp22)
              .orExp(exp23)
              .orExp(exp31)
              .orExp(exp32)
              .orExp(exp33)
              .orExp(exp34)
              .orExp(exp35)
              .orExp(exp36));
    }
    query.distinct();
    return query;
  }

  /**
   * @param rundata
   * @param context
   */
  @Override
  public void loadGroups(RunData rundata, Context context) {
    groupList = AddressBookUtils.getMyGroups(rundata);
    try {
      // マイグループリストの作成
      List<ALEipGroup> myGroups = ALEipUtils.getMyGroups(rundata);

      myGroupList = new ArrayList<ALEipGroup>();
      int length = myGroups.size();
      for (int i = 0; i < length; i++) {
        myGroupList.add(myGroups.get(i));
      }
    } catch (Exception ex) {
      logger.error("AddressBookCorpWordSelectData.loadGroups", ex);
    }
  }

  /**
   * グループリストを取得します。
   *
   * @return
   */
  @Override
  public List<AddressBookGroupResultData> getGroupList() {
    return groupList;
  }

  /**
   * マイグループリストを取得します。
   *
   * @return
   */
  @Override
  public List<ALEipGroup> getMyGroupList() {
    return myGroupList;
  }

  /**
   * アクセス権限チェック用メソッド。 アクセス権限の機能名を返します。
   *
   * @return
   */
  @Override
  public String getAclPortletFeature() {
    return ALAccessControlConstants.POERTLET_FEATURE_ADDRESSBOOK_ADDRESS_INSIDE;
  }

  /** @return */
  @Override
  public String getTemplateFilePath() {
    return "portlets/html/ajax-addressbook-corplist.vm";
  }
}