Provide information for linking Sponsors and partners in project detail view
refs #3139, #3136 git-svn-id: https://svn.libreccm.org/ccm/trunk@5880 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
10c0dc99ce
commit
2fcae22fe7
|
|
@ -142,7 +142,7 @@
|
||||||
<xsl:template match="content-item-layout//*[starts-with(name(), 'orgaunit')]//sciproject-shortdesc">
|
<xsl:template match="content-item-layout//*[starts-with(name(), 'orgaunit')]//sciproject-shortdesc">
|
||||||
<xsl:param name="orgaunit-data" tunnel="yes"/>
|
<xsl:param name="orgaunit-data" tunnel="yes"/>
|
||||||
|
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="$orgaunit-data/projectShortDesc">
|
<xsl:when test="$orgaunit-data/projectShortDesc">
|
||||||
<xsl:value-of select="$orgaunit-data/projectShortDesc"/>
|
<xsl:value-of select="$orgaunit-data/projectShortDesc"/>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
|
|
@ -190,6 +190,9 @@
|
||||||
<xsl:with-param name="funding-code"
|
<xsl:with-param name="funding-code"
|
||||||
tunnel="yes"
|
tunnel="yes"
|
||||||
select="./@fundingCode"/>
|
select="./@fundingCode"/>
|
||||||
|
<xsl:with-param name="sponsor-link"
|
||||||
|
tunnel="yes"
|
||||||
|
select="./@href" />
|
||||||
</xsl:apply-templates>
|
</xsl:apply-templates>
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
@ -202,9 +205,21 @@
|
||||||
</foundry:doc-desc>
|
</foundry:doc-desc>
|
||||||
</foundry:doc>
|
</foundry:doc>
|
||||||
<xsl:template match="content-item-layout//*[starts-with(name(), 'orgaunit')]//sponsors//sponsor//sponsor-name">
|
<xsl:template match="content-item-layout//*[starts-with(name(), 'orgaunit')]//sponsors//sponsor//sponsor-name">
|
||||||
<xsl:param name="sponsor-name" tunnel="yes"/>
|
|
||||||
|
|
||||||
<xsl:value-of select="$sponsor-name"/>
|
<xsl:param name="sponsor-name" tunnel="yes" />
|
||||||
|
<xsl:param name="sponsor-link" tunnel="yes" />
|
||||||
|
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="$sponsor-link">
|
||||||
|
<a href="{$sponsor-link}">
|
||||||
|
<xsl:value-of select="$sponsor-name"/>
|
||||||
|
</a>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:value-of select="$sponsor-name"/>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<foundry:doc section="user" type="template-tag">
|
<foundry:doc section="user" type="template-tag">
|
||||||
|
|
@ -218,6 +233,7 @@
|
||||||
<xsl:param name="funding-code" tunnel="yes"/>
|
<xsl:param name="funding-code" tunnel="yes"/>
|
||||||
|
|
||||||
<xsl:value-of select="$funding-code"/>
|
<xsl:value-of select="$funding-code"/>
|
||||||
|
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<foundry:doc section="user" type="template-tag">
|
<foundry:doc section="user" type="template-tag">
|
||||||
|
|
@ -475,14 +491,27 @@
|
||||||
<xsl:for-each select="$orgaunit-data/involvedOrganizations/organization">
|
<xsl:for-each select="$orgaunit-data/involvedOrganizations/organization">
|
||||||
<xsl:apply-templates select="$layout-tree">
|
<xsl:apply-templates select="$layout-tree">
|
||||||
<xsl:with-param name="involved-organization-name" select="./title" tunnel="yes" />
|
<xsl:with-param name="involved-organization-name" select="./title" tunnel="yes" />
|
||||||
|
<xsl:with-param name="involved-organization-link" select="./links[1]/targetURI" tunnel="yes" />
|
||||||
</xsl:apply-templates>
|
</xsl:apply-templates>
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<xsl:template match="content-item-layout//*[starts-with(name(), 'orgaunit')]//involved-organizations//involved-organization//involved-organization-name">
|
<xsl:template match="content-item-layout//*[starts-with(name(), 'orgaunit')]//involved-organizations//involved-organization//involved-organization-name">
|
||||||
<xsl:param name="involved-organization-name" tunnel="yes" />
|
|
||||||
|
|
||||||
<xsl:value-of select="$involved-organization-name" />
|
<xsl:param name="involved-organization-name" tunnel="yes" />
|
||||||
|
<xsl:param name="involved-organization-link" tunnel="yes" />
|
||||||
|
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="$involved-organization-link">
|
||||||
|
<a href="{$involved-organization-link}">
|
||||||
|
<xsl:value-of select="$involved-organization-name" />
|
||||||
|
</a>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:value-of select="$involved-organization-name" />
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
</xsl:stylesheet>
|
</xsl:stylesheet>
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,22 @@ import com.arsdigita.cms.contenttypes.SciProject;
|
||||||
import com.arsdigita.cms.contenttypes.SciProjectSponsorCollection;
|
import com.arsdigita.cms.contenttypes.SciProjectSponsorCollection;
|
||||||
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
||||||
import com.arsdigita.globalization.GlobalizationHelper;
|
import com.arsdigita.globalization.GlobalizationHelper;
|
||||||
|
import com.arsdigita.persistence.DataCollection;
|
||||||
|
import com.arsdigita.persistence.DataObject;
|
||||||
|
import com.arsdigita.persistence.Session;
|
||||||
|
import com.arsdigita.persistence.SessionManager;
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Summary tab for projects, displays lifespan of the project, the short
|
* Summary tab for projects, displays lifespan of the project, the short
|
||||||
* description, the project team (aka members), a contact, the involved
|
* description, the project team (aka members), a contact, the involved
|
||||||
|
|
@ -33,8 +41,8 @@ import org.apache.log4j.Logger;
|
||||||
public class SciProjectSummaryTab implements GenericOrgaUnitTab {
|
public class SciProjectSummaryTab implements GenericOrgaUnitTab {
|
||||||
|
|
||||||
private final Logger logger = Logger.getLogger(SciProjectSummaryTab.class);
|
private final Logger logger = Logger.getLogger(SciProjectSummaryTab.class);
|
||||||
private final static SciProjectSummaryTabConfig config =
|
private final static SciProjectSummaryTabConfig config
|
||||||
new SciProjectSummaryTabConfig();
|
= new SciProjectSummaryTabConfig();
|
||||||
private String key;
|
private String key;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
@ -64,16 +72,16 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
if (!(orgaunit instanceof SciProject)) {
|
if (!(orgaunit instanceof SciProject)) {
|
||||||
throw new IllegalArgumentException(String.format(
|
throw new IllegalArgumentException(String.format(
|
||||||
"This tab can only process instances of SciProject."
|
"This tab can only process instances of SciProject."
|
||||||
+ "The provided object is of type '%s'.",
|
+ "The provided object is of type '%s'.",
|
||||||
orgaunit.getClass().getName()));
|
orgaunit.getClass().getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
final SciProject project = (SciProject) orgaunit;
|
final SciProject project = (SciProject) orgaunit;
|
||||||
|
|
||||||
final Element projectSummaryElem = parent.newChildElement(
|
final Element projectSummaryElem = parent.newChildElement(
|
||||||
"projectSummary");
|
"projectSummary");
|
||||||
|
|
||||||
generateBasicDataXml(project, projectSummaryElem);
|
generateBasicDataXml(project, projectSummaryElem);
|
||||||
|
|
||||||
|
|
@ -98,7 +106,7 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug(String.format("Generated XML for summary tab of project "
|
logger.debug(String.format("Generated XML for summary tab of project "
|
||||||
+ "'%s' in %d ms.",
|
+ "'%s' in %d ms.",
|
||||||
orgaunit.getName(),
|
orgaunit.getName(),
|
||||||
System.currentTimeMillis() - start));
|
System.currentTimeMillis() - start));
|
||||||
}
|
}
|
||||||
|
|
@ -113,7 +121,7 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
|
||||||
final Element parent) {
|
final Element parent) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
if ((project.getAddendum() != null)
|
if ((project.getAddendum() != null)
|
||||||
&& !project.getAddendum().trim().isEmpty()) {
|
&& !project.getAddendum().trim().isEmpty()) {
|
||||||
final Element addendumElem = parent.newChildElement("addendum");
|
final Element addendumElem = parent.newChildElement("addendum");
|
||||||
addendumElem.setText(project.getAddendum());
|
addendumElem.setText(project.getAddendum());
|
||||||
}
|
}
|
||||||
|
|
@ -126,12 +134,12 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
|
||||||
addDateAttributes(beginElem, project.getBegin());
|
addDateAttributes(beginElem, project.getBegin());
|
||||||
|
|
||||||
final Element beginSkipMonthElem = lifeSpanElem.newChildElement(
|
final Element beginSkipMonthElem = lifeSpanElem.newChildElement(
|
||||||
"beginSkipMonth");
|
"beginSkipMonth");
|
||||||
beginSkipMonthElem.setText(
|
beginSkipMonthElem.setText(
|
||||||
project.getBeginSkipMonth().toString());
|
project.getBeginSkipMonth().toString());
|
||||||
|
|
||||||
final Element beginSkipDayElem = lifeSpanElem.newChildElement(
|
final Element beginSkipDayElem = lifeSpanElem.newChildElement(
|
||||||
"beginSkipDay");
|
"beginSkipDay");
|
||||||
beginSkipDayElem.setText(project.getBeginSkipDay().toString());
|
beginSkipDayElem.setText(project.getBeginSkipDay().toString());
|
||||||
}
|
}
|
||||||
if (project.getEnd() != null) {
|
if (project.getEnd() != null) {
|
||||||
|
|
@ -139,23 +147,23 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
|
||||||
addDateAttributes(endElem, project.getEnd());
|
addDateAttributes(endElem, project.getEnd());
|
||||||
|
|
||||||
final Element endSkipMonthElem = lifeSpanElem.newChildElement(
|
final Element endSkipMonthElem = lifeSpanElem.newChildElement(
|
||||||
"endSkipMonth");
|
"endSkipMonth");
|
||||||
endSkipMonthElem.setText(project.getEndSkipMonth().toString());
|
endSkipMonthElem.setText(project.getEndSkipMonth().toString());
|
||||||
|
|
||||||
final Element endSkipDayElem = lifeSpanElem.newChildElement(
|
final Element endSkipDayElem = lifeSpanElem.newChildElement(
|
||||||
"endSkipDay");
|
"endSkipDay");
|
||||||
endSkipDayElem.setText(project.getEndSkipDay().toString());
|
endSkipDayElem.setText(project.getEndSkipDay().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((project.getProjectShortDescription() != null)
|
if ((project.getProjectShortDescription() != null)
|
||||||
&& !project.getProjectShortDescription().trim().isEmpty()) {
|
&& !project.getProjectShortDescription().trim().isEmpty()) {
|
||||||
final Element shortDescElem = parent.newChildElement("shortDesc");
|
final Element shortDescElem = parent.newChildElement("shortDesc");
|
||||||
shortDescElem.setText(project.getProjectShortDescription());
|
shortDescElem.setText(project.getProjectShortDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug(String.format("Generated basic data XML for project '%s' "
|
logger.debug(String.format("Generated basic data XML for project '%s' "
|
||||||
+ "in %d ms",
|
+ "in %d ms",
|
||||||
project.getName(),
|
project.getName(),
|
||||||
System.currentTimeMillis() - start));
|
System.currentTimeMillis() - start));
|
||||||
}
|
}
|
||||||
|
|
@ -166,30 +174,30 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
|
||||||
|
|
||||||
elem.addAttribute("year",
|
elem.addAttribute("year",
|
||||||
Integer.toString(cal.get(
|
Integer.toString(cal.get(
|
||||||
Calendar.YEAR)));
|
Calendar.YEAR)));
|
||||||
elem.addAttribute("month",
|
elem.addAttribute("month",
|
||||||
Integer.toString(cal.get(
|
Integer.toString(cal.get(
|
||||||
Calendar.MONTH) + 1));
|
Calendar.MONTH) + 1));
|
||||||
elem.addAttribute("day",
|
elem.addAttribute("day",
|
||||||
Integer.toString(cal.get(
|
Integer.toString(cal.get(
|
||||||
Calendar.DAY_OF_MONTH)));
|
Calendar.DAY_OF_MONTH)));
|
||||||
elem.addAttribute("hour",
|
elem.addAttribute("hour",
|
||||||
Integer.toString(cal.get(
|
Integer.toString(cal.get(
|
||||||
Calendar.HOUR_OF_DAY)));
|
Calendar.HOUR_OF_DAY)));
|
||||||
elem.addAttribute("minute",
|
elem.addAttribute("minute",
|
||||||
Integer.toString(cal.get(
|
Integer.toString(cal.get(
|
||||||
Calendar.MINUTE)));
|
Calendar.MINUTE)));
|
||||||
elem.addAttribute("second",
|
elem.addAttribute("second",
|
||||||
Integer.toString(cal.get(
|
Integer.toString(cal.get(
|
||||||
Calendar.SECOND)));
|
Calendar.SECOND)));
|
||||||
|
|
||||||
final Locale negLocale = GlobalizationHelper.getNegotiatedLocale();
|
final Locale negLocale = GlobalizationHelper.getNegotiatedLocale();
|
||||||
final DateFormat dateFormat = DateFormat.getDateInstance(
|
final DateFormat dateFormat = DateFormat.getDateInstance(
|
||||||
DateFormat.MEDIUM, negLocale);
|
DateFormat.MEDIUM, negLocale);
|
||||||
final DateFormat longDateFormat = DateFormat.getDateInstance(
|
final DateFormat longDateFormat = DateFormat.getDateInstance(
|
||||||
DateFormat.LONG, negLocale);
|
DateFormat.LONG, negLocale);
|
||||||
final DateFormat timeFormat = DateFormat.getDateInstance(
|
final DateFormat timeFormat = DateFormat.getDateInstance(
|
||||||
DateFormat.SHORT, negLocale);
|
DateFormat.SHORT, negLocale);
|
||||||
elem.addAttribute("date", dateFormat.format(date));
|
elem.addAttribute("date", dateFormat.format(date));
|
||||||
elem.addAttribute("longDate", longDateFormat.format(date));
|
elem.addAttribute("longDate", longDateFormat.format(date));
|
||||||
elem.addAttribute("time", timeFormat.format(date));
|
elem.addAttribute("time", timeFormat.format(date));
|
||||||
|
|
@ -207,7 +215,7 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
|
||||||
final Element membersElem = parent.newChildElement("members");
|
final Element membersElem = parent.newChildElement("members");
|
||||||
|
|
||||||
final GenericOrganizationalUnitPersonCollection members = project.
|
final GenericOrganizationalUnitPersonCollection members = project.
|
||||||
getPersons();
|
getPersons();
|
||||||
|
|
||||||
while (members.next()) {
|
while (members.next()) {
|
||||||
generateMemberXml(members.getPerson(),
|
generateMemberXml(members.getPerson(),
|
||||||
|
|
@ -250,9 +258,8 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
|
||||||
* membersElem, members.getRoleName(), state); }
|
* membersElem, members.getRoleName(), state); }
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
logger.debug(String.format("Generated members XML for project '%s'"
|
logger.debug(String.format("Generated members XML for project '%s'"
|
||||||
+ "in '%d ms'. MergeMembers is set to '%b'.",
|
+ "in '%d ms'. MergeMembers is set to '%b'.",
|
||||||
project.getName(),
|
project.getName(),
|
||||||
System.currentTimeMillis() - start,
|
System.currentTimeMillis() - start,
|
||||||
config.isMergingMembers()));
|
config.isMergingMembers()));
|
||||||
|
|
@ -266,7 +273,7 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
final GenericPerson member = new GenericPerson(memberId);
|
final GenericPerson member = new GenericPerson(memberId);
|
||||||
logger.debug(String.format("Got domain object for member '%s' "
|
logger.debug(String.format("Got domain object for member '%s' "
|
||||||
+ "in %d ms.",
|
+ "in %d ms.",
|
||||||
member.getFullName(),
|
member.getFullName(),
|
||||||
System.currentTimeMillis() - start));
|
System.currentTimeMillis() - start));
|
||||||
generateMemberXml(member, parent, role, status, state);
|
generateMemberXml(member, parent, role, status, state);
|
||||||
|
|
@ -294,7 +301,7 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
final GenericOrganizationalUnitContactCollection contacts = project.
|
final GenericOrganizationalUnitContactCollection contacts = project.
|
||||||
getContacts();
|
getContacts();
|
||||||
|
|
||||||
if ((contacts == null) || contacts.isEmpty()) {
|
if ((contacts == null) || contacts.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -309,7 +316,7 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
|
||||||
state);
|
state);
|
||||||
}
|
}
|
||||||
logger.debug(String.format("Generated XML for contacts of project '%s'"
|
logger.debug(String.format("Generated XML for contacts of project '%s'"
|
||||||
+ " in %d ms.",
|
+ " in %d ms.",
|
||||||
project.getName(),
|
project.getName(),
|
||||||
System.currentTimeMillis() - start));
|
System.currentTimeMillis() - start));
|
||||||
}
|
}
|
||||||
|
|
@ -320,7 +327,8 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
|
|
||||||
if (contact == null) {
|
if (contact == null) {
|
||||||
logger.warn("Provided contact is null. Will not continue with XML generation for contact.");
|
logger.warn(
|
||||||
|
"Provided contact is null. Will not continue with XML generation for contact.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -337,13 +345,13 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getContactTypeName(final String contactTypeKey) {
|
private String getContactTypeName(final String contactTypeKey) {
|
||||||
final RelationAttributeCollection relAttrs =
|
final RelationAttributeCollection relAttrs
|
||||||
new RelationAttributeCollection();
|
= new RelationAttributeCollection();
|
||||||
relAttrs.addFilter(String.format("attribute = '%s'",
|
relAttrs.addFilter(String.format("attribute = '%s'",
|
||||||
"GenericOrganizationContactTypes"));
|
"GenericOrganizationContactTypes"));
|
||||||
relAttrs.addFilter(String.format("attr_key = '%s'", contactTypeKey));
|
relAttrs.addFilter(String.format("attr_key = '%s'", contactTypeKey));
|
||||||
relAttrs.addFilter(String.format("lang = '%s'", GlobalizationHelper.
|
relAttrs.addFilter(String.format("lang = '%s'", GlobalizationHelper.
|
||||||
getNegotiatedLocale().getLanguage()));
|
getNegotiatedLocale().getLanguage()));
|
||||||
|
|
||||||
if (relAttrs.isEmpty()) {
|
if (relAttrs.isEmpty()) {
|
||||||
return contactTypeKey;
|
return contactTypeKey;
|
||||||
|
|
@ -361,44 +369,44 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
final GenericOrganizationalUnitSuperiorCollection orgas = project.
|
final GenericOrganizationalUnitSuperiorCollection orgas = project.
|
||||||
getSuperiorOrgaUnits();
|
getSuperiorOrgaUnits();
|
||||||
|
|
||||||
if (orgas == null) {
|
if (orgas == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
orgas.addFilter(
|
orgas.addFilter(
|
||||||
String.format("link.assocType = '%s'",
|
String.format("link.assocType = '%s'",
|
||||||
SciProjectInvolvedOrganizationsStep.ASSOC_TYPE));
|
SciProjectInvolvedOrganizationsStep.ASSOC_TYPE));
|
||||||
|
|
||||||
if (orgas.isEmpty()) {
|
if (orgas.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Element involvedElem = parent.newChildElement(
|
final Element involvedElem = parent.newChildElement(
|
||||||
"involvedOrganizations");
|
"involvedOrganizations");
|
||||||
while (orgas.next()) {
|
while (orgas.next()) {
|
||||||
generateInvolvedOrgaXml(orgas.getGenericOrganizationalUnit(),
|
generateInvolvedOrgaXml(orgas.getGenericOrganizationalUnit(),
|
||||||
involvedElem,
|
involvedElem,
|
||||||
state);
|
state);
|
||||||
}
|
}
|
||||||
logger.debug(String.format("Generated XML for involved organizations "
|
logger.debug(String.format("Generated XML for involved organizations "
|
||||||
+ "of project '%s' in %d ms.",
|
+ "of project '%s' in %d ms.",
|
||||||
project.getName(),
|
project.getName(),
|
||||||
System.currentTimeMillis() - start));
|
System.currentTimeMillis() - start));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void generateInvolvedOrgaXml(
|
protected void generateInvolvedOrgaXml(
|
||||||
final GenericOrganizationalUnit involved,
|
final GenericOrganizationalUnit involved,
|
||||||
final Element parent,
|
final Element parent,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
final XmlGenerator generator = new XmlGenerator(involved);
|
final XmlGenerator generator = new XmlGenerator(involved);
|
||||||
generator.setUseExtraXml(false);
|
generator.setUseExtraXml(false);
|
||||||
generator.setItemElemName("organization", "");
|
generator.setItemElemName("organization", "");
|
||||||
generator.generateXML(state, parent, "");
|
generator.generateXML(state, parent, "");
|
||||||
logger.debug(String.format("Generated XML for involved organization "
|
logger.debug(String.format("Generated XML for involved organization "
|
||||||
+ "'%s' in %d ms.",
|
+ "'%s' in %d ms.",
|
||||||
involved.getName(),
|
involved.getName(),
|
||||||
System.currentTimeMillis() - start));
|
System.currentTimeMillis() - start));
|
||||||
}
|
}
|
||||||
|
|
@ -407,8 +415,8 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
|
||||||
final Element parent,
|
final Element parent,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
final GenericOrganizationalUnitSubordinateCollection subProjects =
|
final GenericOrganizationalUnitSubordinateCollection subProjects
|
||||||
project.
|
= project.
|
||||||
getSubordinateOrgaUnits();
|
getSubordinateOrgaUnits();
|
||||||
|
|
||||||
if (subProjects == null) {
|
if (subProjects == null) {
|
||||||
|
|
@ -416,8 +424,8 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
subProjects.addFilter(
|
subProjects.addFilter(
|
||||||
String.format("link.assocType = '%s'",
|
String.format("link.assocType = '%s'",
|
||||||
SciProjectSubProjectsStep.ASSOC_TYPE));
|
SciProjectSubProjectsStep.ASSOC_TYPE));
|
||||||
|
|
||||||
if (subProjects.isEmpty()) {
|
if (subProjects.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -426,12 +434,12 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
|
||||||
final Element subProjectsElem = parent.newChildElement("subProjects");
|
final Element subProjectsElem = parent.newChildElement("subProjects");
|
||||||
while (subProjects.next()) {
|
while (subProjects.next()) {
|
||||||
generateSubProjectXml(
|
generateSubProjectXml(
|
||||||
(SciProject) subProjects.getGenericOrganizationalUnit(),
|
(SciProject) subProjects.getGenericOrganizationalUnit(),
|
||||||
subProjectsElem,
|
subProjectsElem,
|
||||||
state);
|
state);
|
||||||
}
|
}
|
||||||
logger.debug(String.format("Generated XML for subprojects of "
|
logger.debug(String.format("Generated XML for subprojects of "
|
||||||
+ "project '%s' in %d ms.",
|
+ "project '%s' in %d ms.",
|
||||||
project.getName(),
|
project.getName(),
|
||||||
System.currentTimeMillis() - start));
|
System.currentTimeMillis() - start));
|
||||||
}
|
}
|
||||||
|
|
@ -447,7 +455,7 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
|
||||||
generator.generateXML(state, parent, "");
|
generator.generateXML(state, parent, "");
|
||||||
|
|
||||||
logger.debug(String.format("Generated XML for subproject '%s' in"
|
logger.debug(String.format("Generated XML for subproject '%s' in"
|
||||||
+ "%d ms",
|
+ "%d ms",
|
||||||
subProject.getName(),
|
subProject.getName(),
|
||||||
System.currentTimeMillis() - start));
|
System.currentTimeMillis() - start));
|
||||||
}
|
}
|
||||||
|
|
@ -456,33 +464,66 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
|
||||||
final Element parent,
|
final Element parent,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
if ((project.getSponsors() != null)
|
if ((project.getSponsors() != null)
|
||||||
&& !project.getSponsors().isEmpty()) {
|
&& !project.getSponsors().isEmpty()) {
|
||||||
final SciProjectSponsorCollection sponsors = project.getSponsors();
|
final SciProjectSponsorCollection sponsors = project.getSponsors();
|
||||||
final Element sponsorsElem = parent.newChildElement("sponsors");
|
final Element sponsorsElem = parent.newChildElement("sponsors");
|
||||||
while (sponsors.next()) {
|
while (sponsors.next()) {
|
||||||
final Element sponsorElem = sponsorsElem.newChildElement("sponsor");
|
final Element sponsorElem = sponsorsElem.newChildElement(
|
||||||
|
"sponsor");
|
||||||
final GenericOrganizationalUnit sponsor = sponsors.getSponsor();
|
final GenericOrganizationalUnit sponsor = sponsors.getSponsor();
|
||||||
sponsorElem.setText(sponsor.getTitle());
|
sponsorElem.setText(sponsor.getTitle());
|
||||||
|
|
||||||
|
final Optional<String> link = getSponsorLink(sponsor);
|
||||||
|
if (link.isPresent()) {
|
||||||
|
sponsorElem.addAttribute("href", link.get());
|
||||||
|
}
|
||||||
|
|
||||||
if ((sponsors.getFundingCode() != null) && !sponsors.isEmpty()) {
|
if ((sponsors.getFundingCode() != null) && !sponsors.isEmpty()) {
|
||||||
sponsorElem.addAttribute("fundingCode", sponsors.getFundingCode());
|
sponsorElem.addAttribute("fundingCode", sponsors
|
||||||
|
.getFundingCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((project.getFunding() != null)
|
if ((project.getFunding() != null)
|
||||||
&& !project.getFunding().trim().isEmpty()) {
|
&& !project.getFunding().trim().isEmpty()) {
|
||||||
final Element fundingElem = parent.newChildElement("funding");
|
final Element fundingElem = parent.newChildElement("funding");
|
||||||
fundingElem.setText(project.getFunding());
|
fundingElem.setText(project.getFunding());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((project.getFundingVolume() != null)
|
if ((project.getFundingVolume() != null)
|
||||||
&& !project.getFundingVolume().trim().isEmpty()) {
|
&& !project.getFundingVolume().trim().isEmpty()) {
|
||||||
final Element fundingVolumeElem = parent.newChildElement(
|
final Element fundingVolumeElem = parent.newChildElement(
|
||||||
"fundingVolume");
|
"fundingVolume");
|
||||||
fundingVolumeElem.setText(project.getFundingVolume());
|
fundingVolumeElem.setText(project.getFundingVolume());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Optional<String> getSponsorLink(
|
||||||
|
final GenericOrganizationalUnit orga) {
|
||||||
|
|
||||||
|
Session session = SessionManager.getSession();
|
||||||
|
DataCollection links = session
|
||||||
|
.retrieve("com.arsdigita.cms.contentassets.RelatedLink");
|
||||||
|
links.addEqualsFilter("linkOwner.id", orga.getID());
|
||||||
|
links.addEqualsFilter("linkListName", "NONE");
|
||||||
|
links.addOrder("linkOrder");
|
||||||
|
|
||||||
|
if (links.next()) {
|
||||||
|
final DataObject link = links.getDataObject();
|
||||||
|
final String targetUri = (String) link.get("targetURI");
|
||||||
|
|
||||||
|
if (targetUri == null || targetUri.isEmpty()) {
|
||||||
|
return Optional.empty();
|
||||||
|
} else {
|
||||||
|
return Optional.of(targetUri);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class XmlGenerator extends SimpleXMLGenerator {
|
private class XmlGenerator extends SimpleXMLGenerator {
|
||||||
|
|
||||||
private final ContentItem item;
|
private final ContentItem item;
|
||||||
|
|
@ -498,4 +539,5 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue