Skip to content

Commit

Permalink
Merge pull request #248 from sergiofbsilva/FIST-347
Browse files Browse the repository at this point in the history
Include degree type in registration declaration. FIST-347 #resolve
  • Loading branch information
pedrosan7os authored Sep 20, 2016
2 parents 67d1142 + 936054b commit 2c04ad2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

import org.fenixedu.academic.domain.ExecutionYear;
import org.fenixedu.academic.domain.Person;
import org.fenixedu.academic.domain.student.Registration;
import org.joda.time.DateTime;
import org.fenixedu.bennu.core.i18n.BundleUtil;
import org.springframework.stereotype.Service;

import com.itextpdf.text.Document;
Expand Down Expand Up @@ -63,7 +62,7 @@ public RegistrationDeclarationFile generateAndSaveDocumentsForRegistration(Regis
String postalCode = person.getPostalCode();
String curricularYear = Integer.toString(registration.getCurricularYear());
String gender = person.getGender().toString();
String course = registration.getDegree().getName();
String degree = getDegreeDescription(registration);
String naturality = person.getDistrictOfBirth();

Map<String, Object> ctx = new HashMap<>();
Expand All @@ -76,7 +75,7 @@ public RegistrationDeclarationFile generateAndSaveDocumentsForRegistration(Regis
ctx.put("address", address);
ctx.put("postalCode", postalCode);
ctx.put("curricularYear", curricularYear);
ctx.put("course", course);
ctx.put("degree", degree);

try {
byte[] document = generateDocument(ctx, registration);
Expand All @@ -92,6 +91,16 @@ public RegistrationDeclarationFile generateAndSaveDocumentsForRegistration(Regis

}

private String getDegreeDescription(Registration registration) {
String degreeName = registration.getDegree().getFilteredName(ExecutionYear.readCurrentExecutionYear());
if (registration.getDegree().isEmpty()) {
return degreeName;
}
String degreeTypeName = registration.getDegreeType().getName().getContent().replaceAll("Bolonha", ""); //dirty hack until degree type has display form ?
return BundleUtil.getString("resources.RegistrationProcessResources", "registration.document.degree.full.name",
degreeTypeName, degreeName);
}

private byte[] generateDocument(Map<String, Object> ctx, Registration registration)
throws PebbleException, DocumentException, IOException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ address: \n\
\n\
{0}\n\
\n\
\n\
\n\

registration.document.degree.full.name = {0} in {1}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ Pode obter a senha de acesso
\n\
{0}\n\
\n\
\n\
\n\

registration.document.degree.full.name = {0} em {1}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Declara-se, a pedido {% if gender == "MALE"%}do interessado{% else %}da interessada{% endif %}, que {% if gender == "MALE"%}o aluno{% else %}a aluna{% endif %}, {{ studentName }}, {% if gender == "MALE"%}portador{% else %}portadora{% endif %} do {{ documentType }} {{idNumber}}, natural de {{naturality}}, com morada em {{address}}, e código postal {{postalCode}}, no ano lectivo {{executionYear}} está {% if gender == "MALE" %}inscrito{% else %}inscrita{% endif %} no ano curricular {{curricularYear}} do curso de {{course}} deste Instituto.
Declara-se, a pedido {% if gender == "MALE"%}do interessado{% else %}da interessada{% endif %}, que {% if gender == "MALE"%}o aluno{% else %}a aluna{% endif %}, {{ studentName }}, {% if gender == "MALE"%}portador{% else %}portadora{% endif %} do {{ documentType }} {{idNumber}}, natural de {{naturality}}, com morada em {{address}}, e código postal {{postalCode}}, no ano lectivo {{executionYear}} está {% if gender == "MALE" %}inscrito{% else %}inscrita{% endif %} no ano curricular {{curricularYear}} do curso de {{degree}} deste Instituto.

0 comments on commit 2c04ad2

Please sign in to comment.