paper to conference
This commit is contained in:
parent
b662437afe
commit
278e2135bb
@ -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);
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ import ru.ulstu.conference.model.ConferenceDto;
|
||||
import ru.ulstu.conference.model.ConferenceFilterDto;
|
||||
import ru.ulstu.conference.model.ConferenceUser;
|
||||
import ru.ulstu.conference.repository.ConferenceRepository;
|
||||
import ru.ulstu.core.util.DateUtils;
|
||||
import ru.ulstu.deadline.model.Deadline;
|
||||
import ru.ulstu.deadline.service.DeadlineService;
|
||||
import ru.ulstu.name.BaseService;
|
||||
@ -253,7 +254,7 @@ public class ConferenceService extends BaseService {
|
||||
return convert(findAllActive(), ConferenceDto::new);
|
||||
}
|
||||
|
||||
private List<Conference> findAllActive() {
|
||||
public List<Conference> findAllActive() {
|
||||
return conferenceRepository.findAllActive(new Date());
|
||||
}
|
||||
|
||||
@ -339,6 +340,8 @@ public class ConferenceService extends BaseService {
|
||||
|
||||
public Conference createByTitle(String 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.getDeadlines().add(deadlineService.createWithOffset(new Date(), 1, ChronoUnit.WEEKS));
|
||||
return save(conference);
|
||||
|
@ -1,5 +1,8 @@
|
||||
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.util.FacesUtil;
|
||||
import ru.ulstu.deadline.model.Deadline;
|
||||
@ -21,6 +24,8 @@ import java.util.List;
|
||||
@Named
|
||||
@ViewScoped
|
||||
public class PaperView implements Serializable {
|
||||
private static final int MAX_CONFERENCE_TITLE_LENGTH = 20;
|
||||
|
||||
@Inject
|
||||
private PaperService paperService;
|
||||
|
||||
@ -30,6 +35,9 @@ public class PaperView implements Serializable {
|
||||
@Inject
|
||||
private UserService userService;
|
||||
|
||||
@Inject
|
||||
private ConferenceService conferenceService;
|
||||
|
||||
private Paper paper;
|
||||
|
||||
private Date newDeadlineDate;
|
||||
@ -95,4 +103,18 @@ public class PaperView implements Serializable {
|
||||
newDeadlineDescription = "";
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -42,9 +42,24 @@
|
||||
<p:message for="url"/>
|
||||
</div>
|
||||
|
||||
<div class="ui-md-2 ui-g-12">
|
||||
|
||||
<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.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">
|
||||
<!-- <p:outputLabel for="authors" value="Авторы:"/>-->
|
||||
</div>
|
||||
|
@ -42,13 +42,16 @@
|
||||
<p:message for="name"/>
|
||||
</div>
|
||||
<div class="ui-md-2 ui-g-12">
|
||||
<p:link href="/conference/conferenceList.xhtml?id=paperView.paper.conferences[0].id"
|
||||
value="Статья участвует в конференции"
|
||||
rendered="#{not empty paperView.paper.conferences}"/>
|
||||
|
||||
<p:commandButton value="Привязать к конференции"
|
||||
rendered="#{empty paperView.paper.conferences}"
|
||||
disabled="true"/>
|
||||
<p:selectOneMenu id="conference" value="#{paperView.paper.conference}"
|
||||
converter="#{conferenceConverter}">
|
||||
<p:ajax update="mainForm:conferenceId" process="@this"/>
|
||||
<f:selectItem itemValue="#{null}" itemLabel="Конференция для статьи"/>
|
||||
<f:selectItems value="#{paperView.conferences}"
|
||||
var="conference"
|
||||
itemDescription="#{conference.title}"
|
||||
itemLabel="#{paperView.getConferenceTitle(conference)}"
|
||||
itemValue="#{conference}"/>
|
||||
</p:selectOneMenu>
|
||||
</div>
|
||||
<div class="ui-md-3 ui-g-12">
|
||||
<p:outputLabel for="paperStatus" value="Статус:"/>
|
||||
@ -69,6 +72,14 @@
|
||||
</ui:include>
|
||||
</p:panelGrid>
|
||||
</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">
|
||||
<p:outputLabel for="type" value="Тип:"/>
|
||||
</div>
|
||||
|
@ -42,7 +42,7 @@ spring.liquibase.enabled=true
|
||||
ng-tracker.base-url=http://127.0.0.1:8080
|
||||
ng-tracker.undead-user-login=admin
|
||||
ng-tracker.dev-mode=false
|
||||
ng-tracker.debug_email=
|
||||
ng-tracker.debug_email=romanov73@gmail.com
|
||||
ng-tracker.use-https=false
|
||||
ng-tracker.check-run=false
|
||||
ng-tracker.driver-path=
|
||||
|
@ -10,7 +10,7 @@
|
||||
Уважаемый(ая) <span th:text="${user.firstName + ' ' + user.lastName}">Ivan Ivanov</span>
|
||||
</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>" притерпели изменения.
|
||||
<br/>
|
||||
Ознакомтесь с изменениями.
|
||||
|
Loading…
Reference in New Issue
Block a user