com.jalios.jcms
Class MemberImportManager

java.lang.Object
  extended by com.jalios.jcms.MemberImportManager

public class MemberImportManager
extends Object

A manager to be instanciated to import Members from a CSV input file.

Since:
jcms-8
Version:
$Revision: 44328 $
Author:
Sylvain Devaux

Field Summary
static String COMMENT_CHARACTER
          A character to use at start of a line to comment.
protected  int createCount
           
protected  List<String> createdMembersIdList
          The created members id list.
protected  File csvFile
           
protected  com.csvreader.CsvReader csvReader
          the reader that makes the parsing.
protected  Map<String,MemberImport> emailInfoMap
          This map contains the Member objects parsed from CSV.
protected  long endTime
          For debug purpose.
protected  int expectedColumnCout
          Expected headers columns number.
protected  Collection<String> groupIds
           
protected  boolean hasToSendEmail
           
protected  Member importAuthor
           
protected  String importPropertyKey
           
protected  int invalidCount
           
protected  boolean isAnyError
          Is there any error during checking the csv file ?
protected  boolean isBlockingError
           
protected  boolean isLimitReached
          True when member limit is reached.
protected  boolean isSimulation
           
protected  JcmsContext jcmsContext
           
static String LANG_PROPERTY_PREFIX
          Property key prefix.
protected  Map<Integer,MemberImport> lineInfoMap
          This map contains the Member objects parsed from CSV.
static String MEMBER_DC_SRC_COLUMNS_KEY
          A DataController contextMap key, which stores the sources columns of the csv file, as a String[].
protected  List<MemberImport> memberImportList
          The list containing each line.
protected  long previousTime
          For debug purpose.
protected  javax.servlet.http.HttpServletRequest request
           
protected  javax.servlet.http.HttpServletResponse response
           
static String REVISION
          The class revision.
 String separator
          The separator to use, may be selected by UI.
protected  long startTime
          For debug purpose.
protected  int updateCount
           
protected  List<String> updatedMembersIdList
          The update members id list.
protected  String userLang
           
 
Constructor Summary
MemberImportManager(JcmsContext jcmsContext)
           
 
Method Summary
 String[] filterGroupsToProposedWorkspaces(String[] chosenGroupIds, Set<Workspace> wsSet)
          Utility method to control that all chosen groups belongs to given workspace Set.
 int getCreateCount()
           
 File getCsvFile()
           
 int getInvalidCount()
           
 List<MemberImport> getMemberInfoList()
           
 String getSeparator()
           
 int getUpdateCount()
           
 boolean hasToSendEmail()
           
 boolean isAnyError()
           
 boolean isBlockingError()
           
static boolean isEnabled()
           
 boolean isSimulation()
           
 boolean performImport()
          Iterate on memberImportList, and create or update each member.
 void prepareImport()
          Expected format : Name,First name,Email,Login,Organization,Department,JobTitle,Phone,Mobile
May be called directly (in this case, isSimulation should be true).
 void setCsvFile(File csvFile)
           
 void setGroupIds(Collection<String> groupIds)
           
 void setHasToSendEmail(boolean hasToSendEmail)
           
 void setRequest(javax.servlet.http.HttpServletRequest request)
           
 void setResponse(javax.servlet.http.HttpServletResponse response)
           
 void setSeparator(String separator)
           
 void setSimulation(boolean isSimulation)
           
 ControllerStatus validateCsvFile()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
The class revision.

Since:
jcms-8
See Also:
Constant Field Values

MEMBER_DC_SRC_COLUMNS_KEY

public static final String MEMBER_DC_SRC_COLUMNS_KEY
A DataController contextMap key, which stores the sources columns of the csv file, as a String[].

See Also:
Constant Field Values

COMMENT_CHARACTER

public static final String COMMENT_CHARACTER
A character to use at start of a line to comment.

Since:
jcms-8
See Also:
Constant Field Values

isSimulation

protected boolean isSimulation

importPropertyKey

protected String importPropertyKey

groupIds

protected Collection<String> groupIds

csvFile

protected File csvFile

isLimitReached

protected boolean isLimitReached
True when member limit is reached.


request

protected javax.servlet.http.HttpServletRequest request

response

protected javax.servlet.http.HttpServletResponse response

LANG_PROPERTY_PREFIX

public static final String LANG_PROPERTY_PREFIX
Property key prefix.

See Also:
Constant Field Values

expectedColumnCout

protected int expectedColumnCout
Expected headers columns number. Used to check the file format.


importAuthor

protected Member importAuthor

hasToSendEmail

protected boolean hasToSendEmail

startTime

protected long startTime
For debug purpose.


endTime

protected long endTime
For debug purpose.


previousTime

protected long previousTime
For debug purpose.


csvReader

protected com.csvreader.CsvReader csvReader
the reader that makes the parsing.


separator

public String separator
The separator to use, may be selected by UI.


jcmsContext

protected JcmsContext jcmsContext

userLang

protected String userLang

lineInfoMap

protected Map<Integer,MemberImport> lineInfoMap
This map contains the Member objects parsed from CSV.
The key is the csv line.
It is used in the UI to print informations about the file format.


memberImportList

protected List<MemberImport> memberImportList
The list containing each line.


emailInfoMap

protected Map<String,MemberImport> emailInfoMap
This map contains the Member objects parsed from CSV.
The key is the member email.
It allows to avoid 2 lines on same email.
This map will be iterated again, to perform operation (C or U).


createCount

protected int createCount

updateCount

protected int updateCount

invalidCount

protected int invalidCount

isBlockingError

protected boolean isBlockingError

isAnyError

protected boolean isAnyError
Is there any error during checking the csv file ?


createdMembersIdList

protected List<String> createdMembersIdList
The created members id list. Used to show infos after import.


updatedMembersIdList

protected List<String> updatedMembersIdList
The update members id list. Used to show infos after import.

Constructor Detail

MemberImportManager

public MemberImportManager(JcmsContext jcmsContext)
Parameters:
jcmsContext -
Since:
jcms-8
Method Detail

isSimulation

public boolean isSimulation()
Returns:
the isSimulation
Since:
jcms-8

setSimulation

public void setSimulation(boolean isSimulation)
Parameters:
isSimulation - the isSimulation to set
Since:
jcms-8

getCsvFile

public File getCsvFile()
Returns:
the csvFile
Since:
jcms-8

setCsvFile

public void setCsvFile(File csvFile)
Parameters:
csvFile - the csvFile to set
Since:
jcms-8

getMemberInfoList

public List<MemberImport> getMemberInfoList()
Returns:
the memberInfoList
Since:
jcms-8

isAnyError

public boolean isAnyError()
Returns:
the isAnyError
Since:
jcms-8

getCreateCount

public int getCreateCount()
Returns:
the createCount
Since:
jcms-8

getUpdateCount

public int getUpdateCount()
Returns:
the updateCount
Since:
jcms-8

getInvalidCount

public int getInvalidCount()
Returns:
the invalidCount
Since:
jcms-8

getSeparator

public String getSeparator()
Returns:
the separator
Since:
jcms-8

isBlockingError

public boolean isBlockingError()
Returns:
the isBlockingError
Since:
jcms-8

setRequest

public void setRequest(javax.servlet.http.HttpServletRequest request)
Parameters:
request - the request to set
Since:
jcms-8

setResponse

public void setResponse(javax.servlet.http.HttpServletResponse response)
Parameters:
response - the response to set
Since:
jcms-8

setSeparator

public void setSeparator(String separator)
Parameters:
separator - the separator to set
Since:
jcms-8

isEnabled

public static boolean isEnabled()
Returns:
true if Member CSV import is enabled.
Since:
jcms-8

hasToSendEmail

public boolean hasToSendEmail()
Returns:
the hasToSendEmail
Since:
jcms-8

setHasToSendEmail

public void setHasToSendEmail(boolean hasToSendEmail)
Parameters:
hasToSendEmail - the hasToSendEmail to set
Since:
jcms-8

setGroupIds

public void setGroupIds(Collection<String> groupIds)
Parameters:
groupIds - the groupIds to set
Since:
jcms-8

prepareImport

public void prepareImport()
                   throws IOException
Expected format : Name,First name,Email,Login,Organization,Department,JobTitle,Phone,Mobile
May be called directly (in this case, isSimulation should be true).
May be called by performImport (in this case, isSimulation should be false).

If isSimulation is true, a warning message about memberLimitController may be added to jcmsContext. Else, this message should be managed by #performSave(MemberImport).

Throws:
IOException
Since:
jcms-8

performImport

public boolean performImport()
Iterate on memberImportList, and create or update each member.

Returns:
true if import was successfull.
Since:
jcms-8

validateCsvFile

public ControllerStatus validateCsvFile()
                                 throws IOException
Returns:
true if CSV file has correct headers.
Throws:
IOException
Since:
jcms-8

filterGroupsToProposedWorkspaces

public String[] filterGroupsToProposedWorkspaces(String[] chosenGroupIds,
                                                 Set<Workspace> wsSet)
Utility method to control that all chosen groups belongs to given workspace Set.

Parameters:
chosenGroupIds - the Group ids to validate.
wsSet - the workspace Set of the loggedMember.
Returns:
the controlled group list.
Since:
jcms-8


Copyright © 2001-2010 Jalios SA. All Rights Reserved.