paper to conference

This commit is contained in:
Anton Romanov 2020-04-27 20:13:19 +04:00
parent b662437afe
commit 278e2135bb
7 changed files with 92 additions and 12 deletions

View File

@ -0,0 +1,29 @@
package ru.ulstu.conference.controller;
import org.springframework.stereotype.Service;
import ru.ulstu.conference.model.Conference;
import ru.ulstu.conference.service.ConferenceService;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.inject.Inject;
@Service
public class ConferenceConverter implements Converter {
@Inject
private ConferenceService conferenceService;
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
return value == null || value.equals("") ? null : conferenceService.findOne(Integer.valueOf(value));
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
return value == null
? ""
: (value.getClass().equals(Conference.class) ? ((Conference) value).getId().toString() : null);
}
}

View File

@ -11,6 +11,7 @@ import ru.ulstu.conference.model.ConferenceDto;
import ru.ulstu.conference.model.ConferenceFilterDto; import ru.ulstu.conference.model.ConferenceFilterDto;
import ru.ulstu.conference.model.ConferenceUser; import ru.ulstu.conference.model.ConferenceUser;
import ru.ulstu.conference.repository.ConferenceRepository; import ru.ulstu.conference.repository.ConferenceRepository;
import ru.ulstu.core.util.DateUtils;
import ru.ulstu.deadline.model.Deadline; import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.deadline.service.DeadlineService; import ru.ulstu.deadline.service.DeadlineService;
import ru.ulstu.name.BaseService; import ru.ulstu.name.BaseService;
@ -253,7 +254,7 @@ public class ConferenceService extends BaseService {
return convert(findAllActive(), ConferenceDto::new); return convert(findAllActive(), ConferenceDto::new);
} }
private List<Conference> findAllActive() { public List<Conference> findAllActive() {
return conferenceRepository.findAllActive(new Date()); return conferenceRepository.findAllActive(new Date());
} }
@ -339,6 +340,8 @@ public class ConferenceService extends BaseService {
public Conference createByTitle(String newConferenceTitle) { public Conference createByTitle(String newConferenceTitle) {
Conference conference = new Conference(newConferenceTitle); Conference conference = new Conference(newConferenceTitle);
conference.setBeginDate(DateUtils.localDateToDate(DateUtils.convertToLocalDate(new Date()).plus(1, ChronoUnit.WEEKS)));
conference.setEndDate(DateUtils.localDateToDate(DateUtils.convertToLocalDate(new Date()).plus(2, ChronoUnit.WEEKS)));
conference.getUsers().add(new ConferenceUser(userService.getCurrentUser())); conference.getUsers().add(new ConferenceUser(userService.getCurrentUser()));
conference.getDeadlines().add(deadlineService.createWithOffset(new Date(), 1, ChronoUnit.WEEKS)); conference.getDeadlines().add(deadlineService.createWithOffset(new Date(), 1, ChronoUnit.WEEKS));
return save(conference); return save(conference);

View File

@ -1,5 +1,8 @@
package ru.ulstu.paper.controller; package ru.ulstu.paper.controller;
import org.apache.commons.lang3.StringUtils;
import ru.ulstu.conference.model.Conference;
import ru.ulstu.conference.service.ConferenceService;
import ru.ulstu.core.navigation.Page; import ru.ulstu.core.navigation.Page;
import ru.ulstu.core.util.FacesUtil; import ru.ulstu.core.util.FacesUtil;
import ru.ulstu.deadline.model.Deadline; import ru.ulstu.deadline.model.Deadline;
@ -21,6 +24,8 @@ import java.util.List;
@Named @Named
@ViewScoped @ViewScoped
public class PaperView implements Serializable { public class PaperView implements Serializable {
private static final int MAX_CONFERENCE_TITLE_LENGTH = 20;
@Inject @Inject
private PaperService paperService; private PaperService paperService;
@ -30,6 +35,9 @@ public class PaperView implements Serializable {
@Inject @Inject
private UserService userService; private UserService userService;
@Inject
private ConferenceService conferenceService;
private Paper paper; private Paper paper;
private Date newDeadlineDate; private Date newDeadlineDate;
@ -95,4 +103,18 @@ public class PaperView implements Serializable {
newDeadlineDescription = ""; newDeadlineDescription = "";
newDeadlineDate = new Date(); newDeadlineDate = new Date();
} }
public List<Conference> getConferences() {
return conferenceService.findAllActive();
}
public String getConferenceTitle(Conference conference) {
if (conference == null) {
return null;
}
if (conference.getTitle().length() > MAX_CONFERENCE_TITLE_LENGTH) {
return StringUtils.truncate(conference.getTitle(), MAX_CONFERENCE_TITLE_LENGTH) + "...";
}
return conference.getTitle();
}
} }

View File

@ -42,9 +42,24 @@
<p:message for="url"/> <p:message for="url"/>
</div> </div>
<div class="ui-md-2 ui-g-12"> <div class="ui-md-3 ui-g-12">
<h:outputLabel value="Дата начала:"/>
</div> </div>
<div class="ui-md-7 ui-g-12">
<p:datePicker value="#{conferenceView.conference.beginDate}" placeholder="Введите дату"
pattern="dd.MM.yyyy"/>
</div>
<div class="ui-md-3 ui-g-12">
<h:outputLabel value="Дата окончания:"/>
</div>
<div class="ui-md-7 ui-g-12">
<p:datePicker value="#{conferenceView.conference.endDate}" placeholder="Введите дату"
pattern="dd.MM.yyyy"/>
</div>
<div class="ui-md-3 ui-g-12"> <div class="ui-md-3 ui-g-12">
<!-- <p:outputLabel for="authors" value="Авторы:"/>--> <!-- <p:outputLabel for="authors" value="Авторы:"/>-->
</div> </div>

View File

@ -42,13 +42,16 @@
<p:message for="name"/> <p:message for="name"/>
</div> </div>
<div class="ui-md-2 ui-g-12"> <div class="ui-md-2 ui-g-12">
<p:link href="/conference/conferenceList.xhtml?id=paperView.paper.conferences[0].id" <p:selectOneMenu id="conference" value="#{paperView.paper.conference}"
value="Статья участвует в конференции" converter="#{conferenceConverter}">
rendered="#{not empty paperView.paper.conferences}"/> <p:ajax update="mainForm:conferenceId" process="@this"/>
<f:selectItem itemValue="#{null}" itemLabel="Конференция для статьи"/>
<p:commandButton value="Привязать к конференции" <f:selectItems value="#{paperView.conferences}"
rendered="#{empty paperView.paper.conferences}" var="conference"
disabled="true"/> itemDescription="#{conference.title}"
itemLabel="#{paperView.getConferenceTitle(conference)}"
itemValue="#{conference}"/>
</p:selectOneMenu>
</div> </div>
<div class="ui-md-3 ui-g-12"> <div class="ui-md-3 ui-g-12">
<p:outputLabel for="paperStatus" value="Статус:"/> <p:outputLabel for="paperStatus" value="Статус:"/>
@ -69,6 +72,14 @@
</ui:include> </ui:include>
</p:panelGrid> </p:panelGrid>
</div> </div>
<div class="ui-md-2 ui-g-12">
<h:outputLink value="#{page.conference}" id="conferenceId"
title="#{paperView.paper.conference.title}"
target="_blank">
#{paperView.getConferenceTitle(paperView.paper.conference)}
<f:param name="id" value="#{paperView.paper.conference.id}"/>
</h:outputLink>
</div>
<div class="ui-md-3 ui-g-12"> <div class="ui-md-3 ui-g-12">
<p:outputLabel for="type" value="Тип:"/> <p:outputLabel for="type" value="Тип:"/>
</div> </div>

View File

@ -42,7 +42,7 @@ spring.liquibase.enabled=true
ng-tracker.base-url=http://127.0.0.1:8080 ng-tracker.base-url=http://127.0.0.1:8080
ng-tracker.undead-user-login=admin ng-tracker.undead-user-login=admin
ng-tracker.dev-mode=false ng-tracker.dev-mode=false
ng-tracker.debug_email= ng-tracker.debug_email=romanov73@gmail.com
ng-tracker.use-https=false ng-tracker.use-https=false
ng-tracker.check-run=false ng-tracker.check-run=false
ng-tracker.driver-path= ng-tracker.driver-path=

View File

@ -10,7 +10,7 @@
Уважаемый(ая) <span th:text="${user.firstName + ' ' + user.lastName}">Ivan Ivanov</span> Уважаемый(ая) <span th:text="${user.firstName + ' ' + user.lastName}">Ivan Ivanov</span>
</p> </p>
<p> <p>
Дедлайны конференции "<a th:href="@{|${baseUrl}/conference /conference.xhtml?id=${conference.id}|}"> Дедлайны конференции "<a th:href="@{|${baseUrl}/conference/conference.xhtml?id=${conference.id}|}">
<span th:text="${conference.title}">Title</span></a>" притерпели изменения. <span th:text="${conference.title}">Title</span></a>" притерпели изменения.
<br/> <br/>
Ознакомтесь с изменениями. Ознакомтесь с изменениями.