Augabe der Kontaktdaten im XML bei der Mitgliederliste von Projekten (SciProject, Ticket #1168)

git-svn-id: https://svn.libreccm.org/ccm/trunk@1597 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2012-04-16 19:47:10 +00:00
parent c0f9126e0e
commit 418b4ddeb2
3 changed files with 121 additions and 106 deletions

View File

@ -127,24 +127,24 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
final Session session = SessionManager.getSession(); final Session session = SessionManager.getSession();
/*final DataCollection profiles = getProfiles(session, /*final DataCollection profiles = getProfiles(session,
path.getProfileOwner(), path.getProfileOwner(),
path.getPreview(), path.getPreview(),
GlobalizationHelper. GlobalizationHelper.
getNegotiatedLocale().getLanguage()); getNegotiatedLocale().getLanguage());
if (profiles.isEmpty()) { if (profiles.isEmpty()) {
response.sendError(HttpServletResponse.SC_NOT_FOUND); response.sendError(HttpServletResponse.SC_NOT_FOUND);
return; return;
} else if (profiles.size() > 1) { } else if (profiles.size() > 1) {
throw new IllegalStateException( throw new IllegalStateException(
"More than one matching members found."); "More than one matching members found.");
} }
profiles.next(); profiles.next();
PublicPersonalProfile profile = PublicPersonalProfile profile =
(PublicPersonalProfile) DomainObjectFactory. (PublicPersonalProfile) DomainObjectFactory.
newInstance(profiles.getDataObject()); newInstance(profiles.getDataObject());
profiles.close();*/ profiles.close();*/
PublicPersonalProfile profile = getProfile( PublicPersonalProfile profile = getProfile(
session, session,
@ -429,17 +429,17 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
final Session session = SessionManager.getSession(); final Session session = SessionManager.getSession();
/*DataCollection profiles = /*DataCollection profiles =
session.retrieve( session.retrieve(
com.arsdigita.cms.contenttypes.PublicPersonalProfile.BASE_DATA_OBJECT_TYPE); com.arsdigita.cms.contenttypes.PublicPersonalProfile.BASE_DATA_OBJECT_TYPE);
profiles.addFilter(String.format("profileUrl = '%s'", profiles.addFilter(String.format("profileUrl = '%s'",
profileOwner)); profileOwner));
if (preview) { if (preview) {
profiles.addFilter(String.format("version = '%s'", profiles.addFilter(String.format("version = '%s'",
ContentItem.DRAFT)); ContentItem.DRAFT));
} else { } else {
profiles.addFilter(String.format("version = '%s'", profiles.addFilter(String.format("version = '%s'",
ContentItem.LIVE)); ContentItem.LIVE));
}*/ }*/
DataCollection profiles = getProfiles(session, DataCollection profiles = getProfiles(session,
profileOwner, profileOwner,
@ -450,11 +450,11 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
languageIndependentItems()); languageIndependentItems());
/*if (profiles.isEmpty()) { /*if (profiles.isEmpty()) {
profiles = getProfiles(session, profiles = getProfiles(session,
profileOwner, profileOwner,
preview, preview,
GlobalizationHelper.LANG_INDEPENDENT); GlobalizationHelper.LANG_INDEPENDENT);
}*/ }*/
if (profiles.size() == 0) { if (profiles.size() == 0) {
response.sendError(HttpServletResponse.SC_NOT_FOUND); response.sendError(HttpServletResponse.SC_NOT_FOUND);
@ -1005,31 +1005,31 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
ContentPage contentPage = ContentPage contentPage =
(ContentPage) item; (ContentPage) item;
/*logger.debug("contentPage.getContentBundle().hasInstance(GlobalizationHelper.getNegotiatedLocale().getLanguage()) = " /*logger.debug("contentPage.getContentBundle().hasInstance(GlobalizationHelper.getNegotiatedLocale().getLanguage()) = "
+ contentPage.getContentBundle(). + contentPage.getContentBundle().
hasInstance(GlobalizationHelper.getNegotiatedLocale(). hasInstance(GlobalizationHelper.getNegotiatedLocale().
getLanguage())); getLanguage()));
if (contentPage.getContentBundle(). if (contentPage.getContentBundle().
hasInstance(GlobalizationHelper.getNegotiatedLocale(). hasInstance(GlobalizationHelper.getNegotiatedLocale().
getLanguage())) { getLanguage())) {
contentPage = contentPage =
(ContentPage) contentPage.getContentBundle(). (ContentPage) contentPage.getContentBundle().
getInstance(GlobalizationHelper.getNegotiatedLocale(). getInstance(GlobalizationHelper.getNegotiatedLocale().
getLanguage()); getLanguage());
item = (ContentItem) contentPage; item = (ContentItem) contentPage;
} else { } else {
logger.error( logger.error(
String.format( String.format(
"Item '%s' not found in a suitable language variant. Negotiated langauge: %s, langugage independent items allowed is %s, language independent code is %s ", "Item '%s' not found in a suitable language variant. Negotiated langauge: %s, langugage independent items allowed is %s, language independent code is %s ",
path.getNavPath(), path.getNavPath(),
GlobalizationHelper.getNegotiatedLocale(). GlobalizationHelper.getNegotiatedLocale().
getLanguage(), getLanguage(),
Kernel.getConfig(). Kernel.getConfig().
languageIndependentItems(), languageIndependentItems(),
GlobalizationHelper.LANG_INDEPENDENT)); GlobalizationHelper.LANG_INDEPENDENT));
response.sendError( response.sendError(
HttpServletResponse.SC_NOT_FOUND); HttpServletResponse.SC_NOT_FOUND);
return; return;
}*/ }*/
if (contentPage.getContentBundle().hasInstance(profile.getLanguage(), if (contentPage.getContentBundle().hasInstance(profile.getLanguage(),
false)) { false)) {
contentPage = contentPage =
@ -1122,30 +1122,30 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
if (item instanceof ContentPage) { if (item instanceof ContentPage) {
ContentPage contentPage = (ContentPage) item; ContentPage contentPage = (ContentPage) item;
/*logger.debug("contentPage.getContentBundle().hasInstance(GlobalizationHelper.getNegotiatedLocale().getLanguage()) = " /*logger.debug("contentPage.getContentBundle().hasInstance(GlobalizationHelper.getNegotiatedLocale().getLanguage()) = "
+ contentPage.getContentBundle(). + contentPage.getContentBundle().
hasInstance(GlobalizationHelper.getNegotiatedLocale(). hasInstance(GlobalizationHelper.getNegotiatedLocale().
getLanguage())); getLanguage()));
if (contentPage.getContentBundle(). if (contentPage.getContentBundle().
hasInstance(GlobalizationHelper.getNegotiatedLocale(). hasInstance(GlobalizationHelper.getNegotiatedLocale().
getLanguage())) { getLanguage())) {
contentPage = (ContentPage) contentPage.getContentBundle(). contentPage = (ContentPage) contentPage.getContentBundle().
getInstance(GlobalizationHelper.getNegotiatedLocale(). getInstance(GlobalizationHelper.getNegotiatedLocale().
getLanguage()); getLanguage());
item = (ContentItem) contentPage; item = (ContentItem) contentPage;
} else { } else {
logger.error( logger.error(
String.format( String.format(
"Item '%s' not found in a suitable language variant. Negotiated langauge: %s, langugage independent items allowed is %s, language independent code is %s ", "Item '%s' not found in a suitable language variant. Negotiated langauge: %s, langugage independent items allowed is %s, language independent code is %s ",
path.getItemPath(), path.getItemPath(),
GlobalizationHelper.getNegotiatedLocale(). GlobalizationHelper.getNegotiatedLocale().
getLanguage(), getLanguage(),
Kernel.getConfig(). Kernel.getConfig().
languageIndependentItems(), languageIndependentItems(),
GlobalizationHelper.LANG_INDEPENDENT)); GlobalizationHelper.LANG_INDEPENDENT));
response.sendError( response.sendError(
HttpServletResponse.SC_NOT_FOUND); HttpServletResponse.SC_NOT_FOUND);
return; return;
}*/ }*/
if (contentPage.getContentBundle().hasInstance(profile. if (contentPage.getContentBundle().hasInstance(profile.
getLanguage(), false)) { getLanguage(), false)) {
item = (ContentPage) contentPage.getContentBundle(). item = (ContentPage) contentPage.getContentBundle().
@ -1187,31 +1187,50 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
final DataCollection profiles = final DataCollection profiles =
session.retrieve( session.retrieve(
com.arsdigita.cms.contenttypes.PublicPersonalProfile.BASE_DATA_OBJECT_TYPE); com.arsdigita.cms.contenttypes.PublicPersonalProfile.BASE_DATA_OBJECT_TYPE);
profiles.addFilter(String.format("profileUrl = '%s'",
profileOwner)); final FilterFactory filterFactory = profiles.getFilterFactory();
final Filter urlFilter = filterFactory.simple(String.format(
"profileUrl = '%s'",
profileOwner));
final Filter versionFilter;
if (preview) { if (preview) {
profiles.addFilter(String.format("version = '%s'", versionFilter = filterFactory.simple(String.format("version = '%s'",
ContentItem.DRAFT)); ContentItem.DRAFT));
} else { } else {
profiles.addFilter(String.format("version = '%s'", versionFilter = filterFactory.simple(String.format("version = '%s'",
ContentItem.LIVE)); ContentItem.LIVE));
} }
if (allowLangIndependent) { final Filter langFilter = filterFactory.simple(String.format(
FilterFactory ff = profiles.getFilterFactory(); "language = '%s'", language));
Filter filter = ff.or().
addFilter(ff.equals("language", language)). profiles.addFilter(urlFilter);
addFilter(ff.and(). profiles.addFilter(versionFilter);
addFilter(ff.equals("language", profiles.addFilter(langFilter);
GlobalizationHelper.LANG_INDEPENDENT)).
addFilter(ff.notIn("parent", if (profiles.isEmpty()) {
"com.arsdigita.navigation.getParentIDsOfMatchedItems"). profiles.reset();
set("language", language))); profiles.addFilter(urlFilter);
profiles.addFilter(filter); profiles.addFilter(versionFilter);
} else { profiles.addFilter(String.format("language = '%s'",
profiles.addFilter(String.format("language = '%s'", language)); GlobalizationHelper.LANG_INDEPENDENT));
} }
// if (allowLangIndependent) {
// FilterFactory ff = profiles.getFilterFactory();
// Filter filter = ff.or().
// addFilter(ff.equals("language", language)).
// addFilter(ff.and().
// addFilter(ff.equals("language",
// GlobalizationHelper.LANG_INDEPENDENT)).
// addFilter(ff.notIn("parent",
// "com.arsdigita.navigation.getParentIDsOfMatchedItems").
// set("language", language)));
// profiles.addFilter(filter);
// } else {
// profiles.addFilter(String.format("language = '%s'", language));
// }
return profiles; return profiles;
} }

View File

@ -14,7 +14,7 @@ import java.util.List;
/** /**
* <p> * <p>
* The class represents a (scientific) project. It extends * This class represents a (scientific) project. It extends
* {@link GenericOrganizationalUnit} and adds * {@link GenericOrganizationalUnit} and adds
* some fields for additional information: * some fields for additional information:
* </p> * </p>

View File

@ -13,15 +13,11 @@ import com.arsdigita.cms.contenttypes.GenericPerson;
import com.arsdigita.cms.contenttypes.SciProject; import com.arsdigita.cms.contenttypes.SciProject;
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.DataQuery;
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.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -265,7 +261,7 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
final PageState state) { final PageState state) {
final long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
final XmlGenerator generator = new XmlGenerator(member); final XmlGenerator generator = new XmlGenerator(member);
generator.setUseExtraXml(false); generator.setUseExtraXml(true);
generator.setItemElemName("member", ""); generator.setItemElemName("member", "");
generator.addItemAttribute("role", role); generator.addItemAttribute("role", role);
generator.generateXML(state, parent, ""); generator.generateXML(state, parent, "");