Commit 3b050320 by Tuomas Riihimäki

Moar import. Some random fixes not to create user automatically

1 parent 1a4f03e3
...@@ -26,6 +26,8 @@ import fi.codecrew.moya.model.ApiApplicationInstance; ...@@ -26,6 +26,8 @@ import fi.codecrew.moya.model.ApiApplicationInstance;
import fi.codecrew.moya.model.ApplicationPermission; import fi.codecrew.moya.model.ApplicationPermission;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.LanEvent; import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.LanEventProperty;
import fi.codecrew.moya.model.LanEventPropertyKey;
import fi.codecrew.moya.model.Role; import fi.codecrew.moya.model.Role;
import fi.codecrew.moya.model.User; import fi.codecrew.moya.model.User;
import fi.codecrew.moya.utilities.PasswordFunctions; import fi.codecrew.moya.utilities.PasswordFunctions;
...@@ -60,6 +62,8 @@ public class JaasBean implements MoyaRealmBeanRemote { ...@@ -60,6 +62,8 @@ public class JaasBean implements MoyaRealmBeanRemote {
private ApiApplicationFacade appfacade; private ApiApplicationFacade appfacade;
@EJB @EJB
private ApiApplicationInstanceFacade appInstanceFacade; private ApiApplicationInstanceFacade appInstanceFacade;
@EJB
private EventBean eventorgbean;
public EventUser tryLogin(String username, String password) { public EventUser tryLogin(String username, String password) {
...@@ -82,7 +86,13 @@ public class JaasBean implements MoyaRealmBeanRemote { ...@@ -82,7 +86,13 @@ public class JaasBean implements MoyaRealmBeanRemote {
eventUser = null; eventUser = null;
user = null; user = null;
} }
if (user != null && eventUser == null) LanEventProperty inviteonly = eventbean.getProperty(LanEventPropertyKey.INVITE_ONLY_EVENT);
boolean createEventuser = true;
if (inviteonly != null && inviteonly.isBooleanValue()) {
createEventuser = false;
}
if (createEventuser && user != null && eventUser == null)
{ {
LanEvent event = eventbean.getCurrentEvent(); LanEvent event = eventbean.getCurrentEvent();
eventUser = new EventUser(user, event, null); eventUser = new EventUser(user, event, null);
......
...@@ -160,7 +160,6 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -160,7 +160,6 @@ public class ReaderBean implements ReaderBeanLocal {
readerfacade.flush(); readerfacade.flush();
logger.info("Creating new accountevent from autoproduct {}", createAc); logger.info("Creating new accountevent from autoproduct {}", createAc);
event.setNotes("Created automatic account event from reader. " + createAc); event.setNotes("Created automatic account event from reader. " + createAc);
} }
event = readerEventFacade.create(event); event = readerEventFacade.create(event);
......
...@@ -635,18 +635,19 @@ public class UserBean implements UserBeanLocal { ...@@ -635,18 +635,19 @@ public class UserBean implements UserBeanLocal {
} }
@Override @Override
public EventUser getEventUser(User user) { public EventUser getEventUser(User user, boolean create) {
if (user == null || user.getId() == null) { if (user == null || user.getId() == null) {
return null; return null;
} }
user = userFacade.find(user.getId()); user = userFacade.find(user.getId());
EventUser ret = eventUserFacade.find(user); EventUser ret = eventUserFacade.find(user);
if (ret == null) if (create && ret == null)
{ {
ret = new EventUser(user, eventBean.getCurrentEvent(), permbean.getCurrentUser()); ret = new EventUser(user, eventBean.getCurrentEvent(), permbean.getCurrentUser());
eventUserFacade.create(ret); eventUserFacade.create(ret);
eventUserFacade.flush(); eventUserFacade.flush();
ret.setCreator(permbean.getCurrentUser());
} }
return ret; return ret;
} }
...@@ -657,7 +658,7 @@ public class UserBean implements UserBeanLocal { ...@@ -657,7 +658,7 @@ public class UserBean implements UserBeanLocal {
EventUser ret = null; EventUser ret = null;
if (user != null) if (user != null)
{ {
ret = this.getEventUser(user); ret = this.getEventUser(user, false);
} }
return ret; return ret;
} }
...@@ -667,9 +668,9 @@ public class UserBean implements UserBeanLocal { ...@@ -667,9 +668,9 @@ public class UserBean implements UserBeanLocal {
{ {
User user = userFacade.findByLogin(username); User user = userFacade.findByLogin(username);
EventUser ret = null; EventUser ret = null;
if (user.checkPassword(password)) if (user != null && user.checkPassword(password))
{ {
ret = this.getEventUser(user); ret = this.getEventUser(user, false);
} }
return ret; return ret;
...@@ -793,7 +794,7 @@ public class UserBean implements UserBeanLocal { ...@@ -793,7 +794,7 @@ public class UserBean implements UserBeanLocal {
public User getUser(Integer id) { public User getUser(Integer id) {
User ret = userFacade.find(id); User ret = userFacade.find(id);
if (!permbean.getCurrentUser().getUser().equals(ret) && permbean.hasPermission(UserPermission.VIEW_ALL)) { if (!permbean.getCurrentUser().getUser().equals(ret) && !permbean.hasPermission(UserPermission.VIEW_ALL)) {
throw new EJBAccessException("Tried to fetch user with id " + id + " from database without sufficient permissions"); throw new EJBAccessException("Tried to fetch user with id " + id + " from database without sufficient permissions");
} }
......
...@@ -72,12 +72,13 @@ public interface UserBeanLocal { ...@@ -72,12 +72,13 @@ public interface UserBeanLocal {
List<Role> findUsersRoles(EventUser u); List<Role> findUsersRoles(EventUser u);
/** /**
* NOTICE! If the user parameter is a persisted object the returned EventUser has a reloaded user, eg changes to the User object are lost! * NOTICE! If the user parameter is a persisted object the returned
* EventUser has a reloaded user, eg changes to the User object are lost!
* *
* @param user * @param user
* @return * @return
*/ */
EventUser getEventUser(User user); EventUser getEventUser(User user, boolean create);
EventUser validateUser(String username, String password); EventUser validateUser(String username, String password);
......
package fi.codecrew.moya.model; package fi.codecrew.moya.model;
public enum LanEventPropertyKey { public enum LanEventPropertyKey {
EVENT_LOGO(Type.DATA, null), EVENT_LOGO(Type.DATA, null),
INVITEMAIL_SUBJECT(Type.TEXT, "Invitation to Moya Online Youth Accumulator"), INVITEMAIL_SUBJECT(Type.TEXT, "Invitation to Moya Online Youth Accumulator"),
INVITEMAIL_CONTENT(Type.TEXT, "You have been invited to an event by {1}.\n\nYou can register to intranet at: {0}."), INVITEMAIL_CONTENT(Type.TEXT, "You have been invited to an event by {1}.\n\nYou can register to intranet at: {0}."),
BILL_PAID_MAIL_SUBJECT(Type.TEXT, "[{0}] Lasku merkitty maksetuksi"), BILL_PAID_MAIL_SUBJECT(Type.TEXT, "[{0}] Lasku merkitty maksetuksi"),
BILL_PAID_MAIL_CONTENT(Type.TEXT, "Laskusi numero {0} on merkitty maksetuksi. Voit nyt siirtyä lippukauppaan varamaan haluamasi paikat. Tervetuloa tapahtumaan!"), BILL_PAID_MAIL_CONTENT(Type.TEXT, "Laskusi numero {0} on merkitty maksetuksi. Voit nyt siirtyä lippukauppaan varamaan haluamasi paikat. Tervetuloa tapahtumaan!"),
PORTAL_EMAIL_ADDRESS(Type.TEXT, "moya@codecrew.fi"), PORTAL_EMAIL_ADDRESS(Type.TEXT, "moya@codecrew.fi"),
PORTAL_EMAIL_NAME(Type.TEXT, "Moya Online Youth Accumulator"), PORTAL_EMAIL_NAME(Type.TEXT, "Moya Online Youth Accumulator"),
ADMIN_MAIL(Type.TEXT, "moya@codecrew.fi"), ADMIN_MAIL(Type.TEXT, "moya@codecrew.fi"),
EVENT_LAYOUT(Type.TEXT, "template1"), EVENT_LAYOUT(Type.TEXT, "template1"),
SHOP_DEFAULT_CASH(Type.BOOL, null), SHOP_DEFAULT_CASH(Type.BOOL, null),
PLACECODE_FROM_USER(Type.BOOL, "1"), PLACECODE_FROM_USER(Type.BOOL, "1"),
PLACECODE_PRINT_ONLY_OWN(Type.BOOL, null), PLACECODE_PRINT_ONLY_OWN(Type.BOOL, null),
CHECK_BILL_STATS_PERMISSION(Type.BOOL, null), CHECK_BILL_STATS_PERMISSION(Type.BOOL, null),
GATHER_OTHER_BILL_INFO(Type.BOOL, null), GATHER_OTHER_BILL_INFO(Type.BOOL, null),
ALLOW_BILLING(Type.BOOL, null), ALLOW_BILLING(Type.BOOL, null),
BILL_EXPIRE_HOURS(Type.LONG, "168"), BILL_EXPIRE_HOURS(Type.LONG, "168"),
TEMPLATE_PROPERTY1(Type.TEXT, null), TEMPLATE_PROPERTY1(Type.TEXT, null),
TEMPLATE_PROPERTY2(Type.TEXT, null), TEMPLATE_PROPERTY2(Type.TEXT, null),
TEMPLATE_PROPERTY3(Type.TEXT, null), TEMPLATE_PROPERTY3(Type.TEXT, null),
TEMPLATE_PROPERTY4(Type.TEXT, null), TEMPLATE_PROPERTY4(Type.TEXT, null),
TEMPLATE_PROPERTY5(Type.TEXT, null), TEMPLATE_PROPERTY5(Type.TEXT, null),
INVITE_ONLY_EVENT(Type.BOOL, null),
; ;
private enum Type { private enum Type {
TEXT, DATE, DATA, BOOL, LONG TEXT, DATE, DATA, BOOL, LONG
}; };
private final String defaultvalue; private final String defaultvalue;
private final Type type; private final Type type;
public boolean isText() { public boolean isText() {
return Type.TEXT.equals(type); return Type.TEXT.equals(type);
} }
public boolean isDate() { public boolean isDate() {
return Type.DATE.equals(type); return Type.DATE.equals(type);
} }
public boolean isData() { public boolean isData() {
return Type.DATA.equals(type); return Type.DATA.equals(type);
} }
public boolean isBoolean() { public boolean isBoolean() {
return Type.BOOL.equals(type); return Type.BOOL.equals(type);
} }
public boolean isLong() {
return Type.LONG.equals(type);
}
private LanEventPropertyKey(Type t, String def) public boolean isLong() {
{ return Type.LONG.equals(type);
this.type = t; }
defaultvalue = def;
}
public String getDefaultvalue() { private LanEventPropertyKey(Type t, String def)
return defaultvalue; {
} this.type = t;
defaultvalue = def;
}
public Type getType() { public String getDefaultvalue() {
return type; return defaultvalue;
} }
public Type getType() {
return type;
}
} }
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<composite:implementation> <composite:implementation>
<h:outputScript library="primefaces" name="jquery/jquery.js" target="head" /> <h:outputScript library="primefaces" name="jquery/jquery.js" target="head" />
<p:dataTable id="user" value="#{userSearchView.results}" var="user" > <p:dataTable id="user" value="#{userSearchView.results}" var="wra" >
<p:column> <p:column>
<f:facet name="header"> <f:facet name="header">
<h:link value="#{i18n['user.nick']}" includeViewParams="true"> <h:link value="#{i18n['user.nick']}" includeViewParams="true">
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<f:param name="page" value="0" /> <f:param name="page" value="0" />
</h:link> </h:link>
</f:facet> </f:facet>
<h:outputText styleClass="hoverable" value="#{(empty user.nick)?'----':user.nick}" /> <h:outputText styleClass="hoverable" value="#{(empty wra.user.nick)?'----':wra.user.nick}" />
</p:column> </p:column>
<p:column> <p:column>
<f:facet name="header"> <f:facet name="header">
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<f:param name="page" value="0" /> <f:param name="page" value="0" />
</h:link> </h:link>
</f:facet> </f:facet>
<h:outputText value="#{user.firstnames}" /> <h:outputText value="#{wra.user.firstnames}" />
</p:column> </p:column>
<p:column> <p:column>
<f:facet name="header"> <f:facet name="header">
...@@ -35,29 +35,33 @@ ...@@ -35,29 +35,33 @@
</h:link> </h:link>
</f:facet> </f:facet>
<h:outputText value="#{user.lastname}" /> <h:outputText value="#{wra.user.lastname}" />
</p:column> </p:column>
<p:column> <p:column>
<h:link outcome="/useradmin/edit" value="#{i18n['user.edit']}">
<f:param name="userid" value="#{user.id}" /> <h:link rendered="#{!empty wra.eventuser}" outcome="/useradmin/edit" value="#{i18n['user.edit']}">
<f:param name="userid" value="#{wra.user.id}" />
</h:link>
<h:link rendered="#{empty wra.eventuser}" outcome="/useradmin/edit" value="#{i18n['user.addToEvent']}" onclick="return confirm('#{i18n['user.confirmUserToEventAdding']}')">
<f:param name="userid" value="#{wra.user.id}" />
</h:link> </h:link>
<!-- <p:commandButton onClick="location.replace('#{request.contextPath}/useradmin/edit.jsf?userid=#{user.id}')">#{i18n['user.edit']}</p:commandButton> <!-- <p:commandButton onClick="location.replace('#{request.contextPath}/useradmin/edit.jsf?userid=#{wra.user.id}')">#{i18n['user.edit']}</p:commandButton>
<p:overlayPanel for="userinfoBtn"> <p:overlayPanel for="userinfoBtn">
<h:panelGrid columns="2"> <h:panelGrid columns="2">
<img style="width:100px;" src="#{request.contextPath}/dydata/userimage/#{user.currentImage.id}.img" alt="image" /> <img style="width:100px;" src="#{request.contextPath}/dydata/userimage/#{wra.user.currentImage.id}.img" alt="image" />
<h:panelGroup> <h:panelGroup>
<h:outputText value="#{user.nick}"/> <br /> <h:outputText value="#{wra.user.nick}"/> <br />
<h:outputText value="#{user.firstnames} #{user.lastname}"/> <br /> <h:outputText value="#{wra.user.firstnames} #{wra.user.lastname}"/> <br />
<hr /> <hr />
<h:outputText value="#{user.address}"/> <br /> <h:outputText value="#{wra.user.address}"/> <br />
<h:outputText value="#{user.zip} #{user.postalTown}"/> <br /> <h:outputText value="#{wra.user.zip} #{wra.user.postalTown}"/> <br />
<br /> <br />
<h:outputText value="#{user.phone}"/> <br /> <h:outputText value="#{wra.user.phone}"/> <br />
<h:outputText value="#{user.email}"/> <br /> <h:outputText value="#{wra.user.email}"/> <br />
</h:panelGroup> </h:panelGroup>
</h:panelGrid> </h:panelGrid>
</p:overlayPanel> </p:overlayPanel>
......
...@@ -8,34 +8,37 @@ ...@@ -8,34 +8,37 @@
<ui:define name="content"> <ui:define name="content">
<h:form id="wrapform"> <h:form id="wrapform">
<h:dataTable id="tbl" border="1" value="#{importView.wrapper}" var="wra">
<h:column>
<h:selectBooleanCheckbox id="skip" value="#{wra.skip}" />
</h:column>
<h:column>
<h:outputText value="#{wra.user.login}" />
</h:column>
<h:column>
<h:outputText value="#{wra.user.firstnames}" />
</h:column>
<h:column>
<h:outputText value="#{wra.user.lastname}" />
</h:column>
<h:column>
<h:outputText value="#{wra.user.email}" />
</h:column>
<h:column>
<h:outputText value="#{wra.user.accountBalance}" />
</h:column>
<h:column>
<h:selectOneRadio id="selected" value="#{wra.selected}" layout="pageDirection" converter="#{userConverter}">
<f:selectItems var="pot" value="#{wra.potential}" itemLabel="#{pot.id}/#{pot.login}/#{pot.firstnames}/#{pot.lastname}" />
</h:selectOneRadio>
</h:column>
</h:dataTable>
<h:commandButton action="#{importView.commitImport}" value="#{i18n['userImport.commit']}" /> <h:commandButton action="#{importView.commitImport}" value="#{i18n['userImport.commit']}" />
</h:form> </h:form>
<h:dataTable id="tbl" border="1" value="#{importView.users}" var="wra">
<h:column>
<h:outputText value="#{wra.user.login}" />
</h:column>
<h:column>
<h:outputText value="#{wra.user.firstnames}" />
</h:column>
<h:column>
<h:outputText value="#{wra.user.lastname}" />
</h:column>
<h:column>
<h:outputText value="#{wra.user.email}" />
</h:column>
<h:column>
<h:outputText value="#{wra.user.email}" />
</h:column>
<h:column>
<h:outputText value="#{wra.user.email}" />
</h:column>
<h:column>
<h:outputText value="#{wra.eventuser.id}" />
</h:column>
</h:dataTable>
</ui:define> </ui:define>
</ui:composition> </ui:composition>
</h:body> </h:body>
......
...@@ -12,11 +12,6 @@ ...@@ -12,11 +12,6 @@
<h:form enctype="multipart/form-data"> <h:form enctype="multipart/form-data">
<h:panelGrid columns="3"> <h:panelGrid columns="3">
<h:outputLabel for="templ" value="#{i18n['importuser.template']}" />
<h:selectOneMenu id="templ" value="#{importView.template}" converter="#{cardTemplateConverter}">
<f:selectItems value="#{importView.templates}" var="templ" itemLabel="#{templ.name}" />
</h:selectOneMenu>
<h:message for="templ" />
<h:outputLabel for="file" value="#{i18n['importuser.file']}"/> <h:outputLabel for="file" value="#{i18n['importuser.file']}"/>
<p:fileUpload id="file" value="#{importView.file}" mode="simple" /> <p:fileUpload id="file" value="#{importView.file}" mode="simple" />
......
...@@ -138,7 +138,7 @@ public class PlaceView extends GenericCDIView { ...@@ -138,7 +138,7 @@ public class PlaceView extends GenericCDIView {
public String reserveForUser() { public String reserveForUser() {
try { try {
EventUser user = userbean.getEventUser(userlist.getRowData()); EventUser user = userbean.getEventUser(userlist.getRowData(), true);
if (placebean.reservePlace(place, user)) { if (placebean.reservePlace(place, user)) {
PlaceGroup newgroup = placebean.buySelectedPlaces(user); PlaceGroup newgroup = placebean.buySelectedPlaces(user);
for (Place p : newgroup.getPlaces()) { for (Place p : newgroup.getPlaces()) {
......
...@@ -19,7 +19,7 @@ public class UserCardWrapper implements Serializable { ...@@ -19,7 +19,7 @@ public class UserCardWrapper implements Serializable {
private transient final ListDataModel<PrintedCard> printedCards; private transient final ListDataModel<PrintedCard> printedCards;
public UserCardWrapper(User u, UserBeanLocal userbean) { public UserCardWrapper(User u, UserBeanLocal userbean) {
user = userbean.getEventUser(u); user = userbean.getEventUser(u, false);
List<PrintedCard> cards = null; List<PrintedCard> cards = null;
if (user != null) { if (user != null) {
cards = user.getPrintedCards(); cards = user.getPrintedCards();
......
package fi.codecrew.moya.web.cdiview.user; package fi.codecrew.moya.web.cdiview.user;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped; import javax.enterprise.context.ConversationScoped;
import javax.inject.Named; import javax.inject.Named;
import org.primefaces.model.UploadedFile;
import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.User;
import fi.codecrew.moya.web.cdiview.GenericCDIView; import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named @Named
...@@ -10,23 +21,24 @@ import fi.codecrew.moya.web.cdiview.GenericCDIView; ...@@ -10,23 +21,24 @@ import fi.codecrew.moya.web.cdiview.GenericCDIView;
public class ImportView extends GenericCDIView { public class ImportView extends GenericCDIView {
private static final long serialVersionUID = -6212627607244029512L; private static final long serialVersionUID = -6212627607244029512L;
//
// private static final long serialVersionUID = -6212627607244029512L;
//
// private String content; // private String content;
// //
// private static final Logger logger = // private static final Logger logger =
// LoggerFactory.getLogger(ImportView.class); // LoggerFactory.getLogger(ImportView.class);
// //
// @EJB
// private UserBeanLocal userbean; @EJB
private UserBeanLocal userbean;
// @EJB // @EJB
// private EventBeanLocal eventbean; // private EventBeanLocal eventbean;
// @EJB // @EJB
// private ProductBeanLocal prodbean; // private ProductBeanLocal prodbean;
// //
// private UploadedFile file; private UploadedFile file;
private ArrayList<ImportWrapper> users;
private Charset UTF8 = Charset.forName("UTF8");
// //
// private ArrayList<ImportWrapper> wrapper; // private ArrayList<ImportWrapper> wrapper;
// //
...@@ -36,156 +48,68 @@ public class ImportView extends GenericCDIView { ...@@ -36,156 +48,68 @@ public class ImportView extends GenericCDIView {
// //
// private List<CardTemplate> templates; // private List<CardTemplate> templates;
// //
// public void initImport() { public void initImport() {
// if (requirePermissions(UserPermission.MODIFY)) if (requirePermissions(UserPermission.MODIFY_ACCOUNTEVENTS)) {
// {
// templates = templatebean.findAll(); }
// super.beginConversation();
// } }
//
// } public String parse()
// {
// public String parse() throws IOException ArrayList<ImportWrapper> ret = new ArrayList<ImportWrapper>();
// {
// byte[] bytes = file.getContents();
// setWrapper(new ArrayList<ImportWrapper>()); if (bytes == null && file.getSize() > 0)
// logger.warn("Got file {} from upload", file); {
// bytes = new byte[(int) file.getSize()];
// LanEvent event = eventbean.getCurrentEvent(); try {
// file.getInputstream().read(bytes);
// if (file == null) } catch (IOException e) {
// { super.addFaceMessage("import.erroruploading");
// return null; return null;
// } }
// }
// BufferedReader str = new BufferedReader(new
// InputStreamReader(file.getInputstream(), Charset.forName("ISO-8859-1"))); String content = new String(bytes, UTF8);
// String[] splittedIds = content.split(";");
// for (String line = ""; line != null; line = str.readLine()) for (String idstr : splittedIds) {
// { int id = 0;
// if (idstr != null && !idstr.isEmpty() && (id = Integer.parseInt(idstr)) > 0)
// if (line == null || line.isEmpty() || line.matches("^id\\t")) {
// { User user = userbean.getUser(id);
// logger.info("skipping line {}", line); if (user != null)
// continue; {
// } ret.add(new ImportWrapper(user, userbean.getEventUser(user, false)));
// // logger.warn("Parsing line {}", line); }
// User usr = new User(); }
// }
// String[] limatch = line.split("\\|");
// if (limatch.length != 19) users = ret;
// { return "commitImport";
// logger.warn("SPlictcount != 19: {}", limatch.length); }
// }
// public static class ImportWrapper
// for (int i = 0; limatch.length > i; ++i) {
// {
// String field = limatch[i]; private final EventUser eventuser;
// // logger.info("Matched loop {}, val {}", i, field); private final User user;
//
// switch (i) public ImportWrapper(User user, EventUser eventUser) {
// { this.user = user;
// case 5: this.eventuser = eventUser;
// usr.setEmail(field); }
// break;
// case 9: public EventUser getEventuser() {
// usr.setPassword(field); return eventuser;
// break; }
// case 10:
// String[] spl = field.split(" ", 2); public User getUser() {
// if (spl.length != 2) { return user;
// usr.setFirstnames(field); }
// } else {
// usr.setFirstnames(spl[0]); }
// usr.setLastname(spl[1]);
// }
//
// break;
//
// case 11:
// if (field != null && !field.isEmpty() && !field.equals("NULL"))
// {
// PrintedCard card = new PrintedCard(usr, template, Calendar.getInstance(),
// true);
// card.setRfidUid(field);
// usr.setPrintedCards(new ArrayList<PrintedCard>());
// usr.getPrintedCards().add(card);
// }
// break;
// case 12:
// usr.setPhone(field);
// break;
// case 13:
// usr.setNotes(new ArrayList<UserNote>());
// UserNote note = new UserNote();
// note.setContent(field);
// note.setEvent(event);
// note.setNotetype(UserNoteType.BANKACCOUNT);
// note.setUser(usr);
// usr.getNotes().add(note);
//
// break;
// case 14:
// usr.setNick(field);
// usr.setLogin(field);
// break;
// case 17:
// UserNote note2 = new UserNote();
// note2.setContent(field);
// note2.setEvent(event);
// note2.setNotetype(UserNoteType.ORGNOTE);
// note2.setUser(usr);
// usr.getNotes().add(note2);
// break;
//
// case 18:
// if (field == null || field.isEmpty() || field.equals("NULL")) {
// break;
// }
// if (usr.getAccountEvents() == null) {
// usr.setAccountEvents(new ArrayList<AccountEvent>());
// }
//
// try {
// AccountEvent ac = new AccountEvent(usr, prodbean.findCreditProduct(), new
// BigDecimal(field), BigDecimal.ONE, Calendar.getInstance());
// usr.getAccountEvents().add(ac);
// } catch (Throwable t) {
// logger.warn("Error parsing count: {}", t);
// }
//
// break;
// default:
// break;
// }
// if (i > 18)
// {
// logger.warn("cols not 18, {}", i);
// break;
// }
//
// }
//
// ImportWrapper wrap = new ImportWrapper(usr);
// getWrapper().add(wrap);
//
// SearchResult<User> srch = null;
// if (usr.getNick() != null && !usr.getNick().isEmpty())
// {
// srch = userbean.getUsers(0, 0, null, usr.getNick());
// wrap.add(srch.getResults());
// }
// if (usr.getEmail() != null && !usr.getEmail().isEmpty())
// {
// srch = userbean.getUsers(0, 0, null, usr.getEmail());
// wrap.add(srch.getResults());
// }
//
// } // end for split lines
// return "/user/commitImport";
//
// }
//
// public String commitImport() // public String commitImport()
// { // {
// for (ImportWrapper w : wrapper) // for (ImportWrapper w : wrapper)
...@@ -239,44 +163,21 @@ public class ImportView extends GenericCDIView { ...@@ -239,44 +163,21 @@ public class ImportView extends GenericCDIView {
// return null; // return null;
// } // }
// //
// public String getContent() {
// return content; public ArrayList<User> getUsers() {
// } return users;
// }
// public void setContent(String content) {
// this.content = content; public void setUsers(ArrayList<User> users) {
// } this.users = users;
// }
// public UploadedFile getFile() {
// return file; public UploadedFile getFile() {
// } return file;
// }
// public void setFile(UploadedFile file) {
// this.file = file; public void setFile(UploadedFile file) {
// } this.file = file;
// }
// public ArrayList<ImportWrapper> getWrapper() {
// return wrapper;
// }
//
// public void setWrapper(ArrayList<ImportWrapper> wrapper) {
// this.wrapper = wrapper;
// }
//
// public List<CardTemplate> getTemplates() {
// return templates;
// }
//
// public void setTemplates(List<CardTemplate> templates) {
// this.templates = templates;
// }
//
// public CardTemplate getTemplate() {
// return template;
// }
//
// public void setTemplate(CardTemplate template) {
// this.template = template;
// }
} }
...@@ -70,7 +70,7 @@ public class RoleView extends GenericCDIView { ...@@ -70,7 +70,7 @@ public class RoleView extends GenericCDIView {
public void addUser() public void addUser()
{ {
EventUser eu = userbean.getEventUser(addableUser); EventUser eu = userbean.getEventUser(addableUser, false);
role = rolebean.addRole(eu, role); role = rolebean.addRole(eu, role);
addableUser = null; addableUser = null;
} }
......
package fi.codecrew.moya.web.cdiview.user; package fi.codecrew.moya.web.cdiview.user;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -18,11 +19,44 @@ import fi.codecrew.moya.model.User; ...@@ -18,11 +19,44 @@ import fi.codecrew.moya.model.User;
import fi.codecrew.moya.util.UserSearchQuery; import fi.codecrew.moya.util.UserSearchQuery;
import fi.codecrew.moya.utilities.SearchQuery.QuerySortOrder; import fi.codecrew.moya.utilities.SearchQuery.QuerySortOrder;
import fi.codecrew.moya.utilities.SearchResult; import fi.codecrew.moya.utilities.SearchResult;
import fi.codecrew.moya.utilities.jpa.ModelInterface;
import fi.codecrew.moya.web.cdiview.PaginationView; import fi.codecrew.moya.web.cdiview.PaginationView;
import fi.codecrew.moya.web.cdiview.user.UserSearchView.UserWrapper;
@Named @Named
@ConversationScoped @ConversationScoped
public class UserSearchView extends PaginationView<User> { public class UserSearchView extends PaginationView<UserWrapper> {
public static class UserWrapper implements ModelInterface {
private final User user;
private final EventUser eventuser;
public UserWrapper(User u, EventUser eventUser) {
this.user = u;
this.eventuser = eventUser;
}
public User getUser() {
return user;
}
public EventUser getEventuser() {
return eventuser;
}
@Override
public Integer getId() {
return user.getId();
}
@Override
public void setId(Integer id) {
user.setId(id);
}
}
/** /**
* *
...@@ -99,7 +133,14 @@ public class UserSearchView extends PaginationView<User> { ...@@ -99,7 +133,14 @@ public class UserSearchView extends PaginationView<User> {
this.setEventUserResults(eventusers.getResults()); this.setEventUserResults(eventusers.getResults());
} }
else { else {
super.setResult(userbean.getUsers(getSearchQuery())); SearchResult<User> result = userbean.getUsers(getSearchQuery());
setResultcount(result.getResultcount());
ArrayList<UserWrapper> res = new ArrayList<UserWrapper>();
for (User u : result.getResults()) {
res.add(new UserWrapper(u, userbean.getEventUser(u, false)));
}
setResults(res);
} }
super.beginConversation(); super.beginConversation();
} }
......
...@@ -141,7 +141,7 @@ public class UserView extends GenericCDIView { ...@@ -141,7 +141,7 @@ public class UserView extends GenericCDIView {
ByteArrayInputStream data = new ByteArrayInputStream(captureEvent.getData()); ByteArrayInputStream data = new ByteArrayInputStream(captureEvent.getData());
UserImage img = userbean.uploadImage(user, "image/png", data, "userimage.png", "Uploaded image"); UserImage img = userbean.uploadImage(user, "image/png", data, "userimage.png", "Uploaded image");
user = userbean.getEventUser(img.getUser()); user = userbean.getEventUser(img.getUser(), false);
// super.navihandler.forward("/admin/adduser/capturesuccess"); // super.navihandler.forward("/admin/adduser/capturesuccess");
if (getCaptureForwardUrl() != null && !getCaptureForwardUrl().isEmpty()) if (getCaptureForwardUrl() != null && !getCaptureForwardUrl().isEmpty())
super.navihandler.forward(getCaptureForwardUrl()); super.navihandler.forward(getCaptureForwardUrl());
...@@ -199,7 +199,7 @@ public class UserView extends GenericCDIView { ...@@ -199,7 +199,7 @@ public class UserView extends GenericCDIView {
croppedImage.getLeft(), croppedImage.getTop(), croppedImage.getLeft(), croppedImage.getTop(),
croppedImage.getWidth(), croppedImage.getHeight()); croppedImage.getWidth(), croppedImage.getHeight());
user = userbean.getEventUser(newImage.getUser()); user = userbean.getEventUser(newImage.getUser(), false);
} catch (IOException e) { } catch (IOException e) {
logger.info("Error converting image", e); logger.info("Error converting image", e);
super.addFaceMessage("user.errorConvertingImage"); super.addFaceMessage("user.errorConvertingImage");
...@@ -246,7 +246,7 @@ public class UserView extends GenericCDIView { ...@@ -246,7 +246,7 @@ public class UserView extends GenericCDIView {
InputStream istr = getImage().getInputstream(); InputStream istr = getImage().getInputstream();
UserImage userimage = userbean.uploadImage(user, getImage().getContentType(), getImage().getInputstream(), getImage().getFileName(), ""); UserImage userimage = userbean.uploadImage(user, getImage().getContentType(), getImage().getInputstream(), getImage().getFileName(), "");
user = userbean.getEventUser(userimage.getUser()); user = userbean.getEventUser(userimage.getUser(), false);
super.addFaceMessage("user.imageUploaded"); super.addFaceMessage("user.imageUploaded");
} }
printedCard = null; printedCard = null;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!