Skip to content

Commit

Permalink
SAK-30322: Rename Sakai Resource Picker to "Search Resources"Changing
Browse files Browse the repository at this point in the history
SAK-30322: Various bug fixes

SAK-30322: Various bug fixes 2

SAK-30322: Various bug fixes 3

SAK-30322: Export button and citation export links

SAK-30322: Fixed test

SAK-30322: Export, print, Last updated links

SAK-30322: Fix indentation

SAK-30322:  Fix indentation

SAK-30322: Fix indentation
  • Loading branch information
nicholaswilson100 committed Mar 7, 2016
1 parent 6121cbb commit f2ff8f1
Show file tree
Hide file tree
Showing 15 changed files with 446 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,26 @@ public int getCountCitations() {
}
return citationNo;
}

public CitationCollectionOrder copy(String collectionId) {

CitationCollectionOrder citationCollectionOrder = new CitationCollectionOrder();

citationCollectionOrder.setCollectionId(collectionId);

citationCollectionOrder.setChildren(this.getChildren());
citationCollectionOrder.setCitationid(this.getCitationid());
citationCollectionOrder.setLocation(this.getLocation());
citationCollectionOrder.setSectiontype(this.getSectiontype());
citationCollectionOrder.setValue(this.getValue());

return citationCollectionOrder;
}

public CitationCollectionOrder copy(String collectionId, String citationId) {

CitationCollectionOrder citationCollectionOrder = copy(collectionId);
citationCollectionOrder.setCitationid(citationId);
return citationCollectionOrder;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2624,6 +2624,8 @@ public TitleComparator(boolean ascending)

protected Map<String, Citation> m_citations = new LinkedHashMap<String, Citation>();

protected List<CitationCollectionOrder> m_nestedCitationCollectionOrders = new ArrayList<CitationCollectionOrder>();

protected Comparator m_comparator = DEFAULT_COMPARATOR;

protected String m_sortOrder;
Expand Down Expand Up @@ -2870,6 +2872,14 @@ public List getCitations()
return citations;
}

public List<CitationCollectionOrder> getNestedCitationCollectionOrders() {
return m_nestedCitationCollectionOrders;
}

public void setNestedCitationCollectionOrders(List<CitationCollectionOrder> m_nestedCitationCollectionOrders) {
this.m_nestedCitationCollectionOrders = m_nestedCitationCollectionOrders;
}

public CitationCollection getCitations(Comparator c)
{
checkForUpdates();
Expand Down Expand Up @@ -3073,6 +3083,15 @@ public void saveCitation(Citation citation)
save(citation);
}

/*
* (non-Javadoc)
*
* @see org.sakaiproject.citation.api.CitationCollection#saveCitationCollectionOrder(org.sakaiproject.citation.api.CitationCollectionOrder)
*/
public void saveCitationCollectionOrder(CitationCollectionOrder citationCollectionOrder)
{
save(citationCollectionOrder);
}
/**
*
* @param comparator
Expand Down Expand Up @@ -3208,6 +3227,35 @@ protected void set(BasicCitationCollection other, boolean isTemporary)
M_log.warn("copy(" + oldCitation.getId() + ") ==> " + newCitation.getId(), e);
}
}

Iterator iterator = other.getNestedCitationCollectionOrders().iterator();
while(iterator.hasNext()) {
CitationCollectionOrder citationCollectionOrder = (CitationCollectionOrder) iterator.next();
if (citationCollectionOrder.isCitation()){
try {
// copy the citation
CitationCollection collection = getCollection(citationCollectionOrder.getCollectionId());
BasicCitation oldCitation = (BasicCitation) collection.getCitation(citationCollectionOrder.getCitationid());
BasicCitation newCitation = new BasicCitation();
newCitation.copy(oldCitation);
newCitation.m_temporary = isTemporary;
this.saveCitation(newCitation);

// copy the citation's citationCollectionOrder
CitationCollectionOrder newCitationCollectionOrder = citationCollectionOrder.copy(this.getId(), newCitation.getId());
this.saveCitationCollectionOrder(newCitationCollectionOrder);

} catch (IdUnusedException e) {
M_log.warn("copying citationcollectionorder(" + citationCollectionOrder.getCitationid() + ") ==> " + citationCollectionOrder.getValue(), e);
}
}
else {
// copy the citationCollectionOrder
CitationCollectionOrder newCitationCollectionOrder = citationCollectionOrder.copy(this.getId());
this.saveCitationCollectionOrder(newCitationCollectionOrder);
}
}

this.m_mostRecentUpdate = TimeService.newTime().getTime();

}
Expand Down Expand Up @@ -3844,6 +3892,8 @@ protected interface Storage

public void saveCitation(Citation edit);

public void saveCitationCollectionOrder(CitationCollectionOrder citationCollectionOrder);

public void saveCollection(CitationCollection collection);

public void saveSection(CitationCollectionOrder citationCollectionOrder);
Expand Down Expand Up @@ -5451,6 +5501,17 @@ public void save(Citation citation)
this.m_storage.saveCitation(citation);
}


/*
* (non-Javadoc)
*
* @see org.sakaiproject.citation.api.CitationService#save(org.sakaiproject.citation.api.CitationCollectionOrder)
*/
public void save(CitationCollectionOrder citationCollectionOrder)
{
this.m_storage.saveCitationCollectionOrder(citationCollectionOrder);
}

public void setIdManager(IdManager idManager)
{
m_idManager = idManager;
Expand Down Expand Up @@ -5650,7 +5711,7 @@ private void copyCitationCollection(Reference reference)
{
ContentResourceEdit edit = contentService.editResource(reference.getId());
String collectionId = new String(edit.getContent());
CitationCollection oldCollection = getCollection(collectionId);
CitationCollection oldCollection = getUnnestedCitationCollection(collectionId);
BasicCitationCollection newCollection = new BasicCitationCollection();
newCollection.copy((BasicCitationCollection) oldCollection);
save(newCollection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,15 @@ public void saveCitation(Citation edit)
this.m_citations.put(edit.getId(), edit);
}


/* (non-Javadoc)
* @see org.sakaiproject.citation.impl.BaseCitationService.Storage#saveCitationCollectionOrder(org.sakaiproject.citation.api.CitationCollectionOrder)
*/
public void saveCitationCollectionOrder(CitationCollectionOrder citationCollectionOrder)
{
this.m_citationCollections.put(citationCollectionOrder.getLocation(), citationCollectionOrder);
}

/* (non-Javadoc)
* @see org.sakaiproject.citation.impl.BaseCitationService.Storage#saveCollection(java.util.Collection)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.*;

import javax.servlet.http.HttpServletRequest;
Expand All @@ -41,19 +42,14 @@
import org.sakaiproject.component.cover.ServerConfigurationService;
import org.sakaiproject.content.api.ContentResource;
import org.sakaiproject.content.cover.ContentHostingService;
import org.sakaiproject.entity.api.EntityAccessOverloadException;
import org.sakaiproject.entity.api.EntityCopyrightException;
import org.sakaiproject.entity.api.EntityNotDefinedException;
import org.sakaiproject.entity.api.EntityPermissionException;
import org.sakaiproject.entity.api.HttpAccess;
import org.sakaiproject.entity.api.Reference;
import org.sakaiproject.entity.api.ResourceProperties;
import org.sakaiproject.entity.api.*;
import org.sakaiproject.event.api.Event;
import org.sakaiproject.event.cover.EventTrackingService;
import org.sakaiproject.exception.IdUnusedException;
import org.sakaiproject.exception.PermissionException;
import org.sakaiproject.exception.ServerOverloadException;
import org.sakaiproject.exception.TypeException;
import org.sakaiproject.tool.api.SessionManager;
import org.sakaiproject.util.ResourceLoader;
import org.sakaiproject.util.Validator;

Expand Down Expand Up @@ -131,6 +127,8 @@ protected void handleExportRequest(HttpServletRequest req, HttpServletResponse r
Reference ref, String format, String subtype)
throws EntityNotDefinedException, EntityAccessOverloadException, EntityPermissionException
{
SessionManager sessionManager = ComponentManager.get(SessionManager.class);
org.sakaiproject.content.api.ContentHostingService contentHostingService = ComponentManager.get(org.sakaiproject.content.api.ContentHostingService.class);
if(! ContentHostingService.allowGetResource(req.getParameter("resourceId")))
{
String url = (req.getRequestURL()).toString();
Expand All @@ -149,7 +147,25 @@ protected void handleExportRequest(HttpServletRequest req, HttpServletResponse r

if(org.sakaiproject.citation.api.CitationService.RIS_FORMAT.equals(format))
{
String citationCollectionId = req.getParameter("citationCollectionId");
String citationCollectionId = null;
ContentResource resource = null;
try {
resource = contentHostingService.getResource(req.getParameter("resourceId"));
citationCollectionId = new String(resource.getContent());
}
catch (PermissionException e) {
throw new EntityPermissionException(sessionManager.getCurrentSessionUserId(), "handleExportRequest", ref.getReference());
}
catch (IdUnusedException e) {
throw new EntityNotDefinedException(ref.getReference());
}
catch (TypeException e) {
throw new IllegalStateException("Resource Mismatch: " + ref.getReference(), e);
}
catch (ServerOverloadException e){
throw new EntityAccessOverloadException(ref.getReference());
}

List<String> citationIds = new java.util.ArrayList<String>();
CitationCollection collection = null;
try
Expand Down Expand Up @@ -316,9 +332,26 @@ protected void handleViewRequest(HttpServletRequest req, HttpServletResponse res
List<Citation> citations = collection.getCitations();
String contentCollectionId = resource.getContainingCollection().getId();

out.println("<div class=\"portletBody\">\n\t<div class=\"indnt1 citationList\" style=\"margin-left: 0px !important;\">");
out.println("\t<div style=\"position:relative;width:100%; min-height:90px;\">" + "<div class=\"listTitle\" style=\"position: absolute; width: 100%; background-color:" + ServerConfigurationService.getString("official.institution.background.colour") +"; \"><h1 style=\"color:" + ServerConfigurationService.getString("official.institution.text.colour") + ";\">" + Validator.escapeHtml(title) + "</h1></div>");
out.println("\t</div>");

String exportParams = "?resourceDisplayName=" + resource.getProperties().getProperty(ResourceProperties.PROP_DISPLAY_NAME) + "&resourceId=" + resource.getId();
String exportUrlAll = fullCollection.getUrl(org.sakaiproject.citation.api.CitationService.REF_TYPE_EXPORT_RIS_ALL) + exportParams;
String displayDate = null;
try {
displayDate = new SimpleDateFormat("dd/MM/yyyy", rb.getLocale()).format(properties.getDateProperty(ResourceProperties.PROP_MODIFIED_DATE));
} catch (EntityPropertyNotDefinedException e) {
m_log.warn("CitationListAccessServlet.handleViewRequest() : Property name requested is not defined - for contentCollectionId" + contentCollectionId);
} catch (EntityPropertyTypeException e) {
m_log.warn("CitationListAccessServlet.handleViewRequest() : Named property found does not match the type of access requested - for contentCollectionId" + contentCollectionId);
}

out.println("<div class=\"portletBody\">\n\t<div class=\"listWidth citationList\">");
out.println("\t<div style=\"width: 100%; height: 90px; line-height: 90px; background-color:" +
ServerConfigurationService.getString("official.institution.background.colour") +"; \">" +
"<div class=\"banner\"><h1 style=\" margin-left:15px; color:" + ServerConfigurationService.getString("official.institution.text.colour") + ";\">" +
Validator.escapeHtml(title) + "</h1></div> " +
"<div class=\"bannerLinks\">" +
"<a class=\"export\" href=" + exportUrlAll + ">Export</a>" + "<a class=\"print\" target=\"_blank\" href=" + req.getRequestURL() + "?printView" + ">Print</a>" +
"<div class=\"lastUpdated\">Last updated: " + displayDate + "</div>" + "</div>" + "" + " </div>");
out.println("<div style=\"clear:both;\"></div>");
if( introduction != null && !introduction.trim().equals("") )
{
Expand Down Expand Up @@ -418,9 +451,9 @@ private void displayCitations(PrintWriter out, List<Citation> citations, Citatio
+ "\" class=\"googleBookCover\"></a></div><div style=\"float:left;\"><div><a href=\"" + Validator.escapeHtml(href) + "\" target=\"_blank\">"
+ Validator.escapeHtml( (String)citation.getCitationProperty( Schema.TITLE, true ) ) + "</a></div>");
out.println("\t\t\t\t<div class=\"creatorDiv\">" + Validator.escapeHtml( citation.getCreator() ) + "</div>");
out.println("\t\t\t\t<div class=\"sourceDiv\">" + Validator.escapeHtml( citation.getSource() ) + "</div></div>");
out.println("\t\t\t\t<div class=\"sourceDiv\">" + Validator.escapeHtml( citation.getSource() ) + "</div>");

out.println("\t\t\t<div class=\"imgDiv\"><table class=\"listHier lines nolines\" cellpadding=\"0\" cellspacing=\"0\">");
out.println("\t\t\t<div><table class=\"listHier lines nolines\" cellpadding=\"0\" cellspacing=\"0\">");

Schema schema = citation.getSchema();
if(schema == null) {
Expand Down Expand Up @@ -478,7 +511,7 @@ private void displayCitations(PrintWriter out, List<Citation> citations, Citatio
}
}
}
out.println("\t\t\t</table></div>");
out.println("\t\t\t</table></div></div>");

// rhs links
out.println("\t\t\t<div class=\"itemAction links\" style=\"width:20%\">");
Expand Down Expand Up @@ -527,6 +560,9 @@ private void displayCitations(PrintWriter out, List<Citation> citations, Citatio
out.println("\t\t<div id=\"details_" + escapedId + "\" class=\"citationDetails\" style=\"display: none;\">");
out.println("\t\t\t<table class=\"listHier lines nolines\" cellpadding=\"0\" cellspacing=\"0\">");

out.println("\t\t<div class=\"availabilityHeader\"></div>");

out.println("\t\t</td>");
fields = schema.getFields();
fieldIt = fields.iterator();

Expand Down Expand Up @@ -609,7 +645,7 @@ private void displayNestedSections(String title, String citationCollectionId, or
CitationCollectionOrder nestedCollection = citationService.getNestedCollection(citationCollectionId);
int nestedSectionsSize = nestedCollection.getChildren().size();

out.println("<ol class='serialization vertical h1NestedLevel' style='padding:0;'>");
out.println("<ol class='serialization viewCitations h1NestedLevel' style='padding:0;'>");

// h1 sections
if (nestedSectionsSize > 0) {
Expand All @@ -626,7 +662,7 @@ private void displayNestedSections(String title, String citationCollectionId, or
(nestedSection.getChildren().size() > 0 ? "<img border='0' width='16' height='16' align='top' alt='Citation View' " +
"src='/library/image/sakai/white-arrow-right.gif' class='toggleIcon accordionArrow' id='" + toggleImg + "'>" : "") + "</div>" +
"<div id = '" + editorDivId + "' class='editor accordionDiv'>" +
nestedSection.getValue() + (citationNo!=0 ? " (" + citationNo + " citations)" : "") + "</div></div>");
(nestedSection.getValue()!=null ? nestedSection.getValue() : "") + (citationNo!=0 ? " (" + citationNo + " citations)" : "") + "</div></div>");

// h2 sections
if (nestedSection.getChildren().size() > 0) {
Expand All @@ -642,7 +678,7 @@ private void displayNestedSections(String title, String citationCollectionId, or
out.println("<li id = '" + linkId + "' class='h2Section' data-location='" + h2Section.getLocation() + "' data-sectiontype='" +
h2Section.getSectiontype() + "' style='background: #cef none repeat scroll 0 0;'>" +
"<div id = '" + editorDivId + "' class='editor h2Editor' style='min-height:30px; padding:5px;'>" +
h2Section.getValue() + "</div>");
(h2Section.getValue()!=null ? h2Section.getValue() : "") + "</div>");

// h3 sections
if (h2Section.getChildren().size() > 0) {
Expand All @@ -658,7 +694,7 @@ private void displayNestedSections(String title, String citationCollectionId, or
h3Section.getSectiontype() + "'>" +
"<div style='' id = '" + editorDivId + "' class='editor h3Editor' " +
"style='padding-left:20px; '>" +
"<div style=''>" + h3Section.getValue() + "</div></div>");
"<div style=''>" + (h3Section.getValue()!=null ? h3Section.getValue() : "") + "</div></div>");

// nested citations
if (h3Section.getChildren().size() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ public void saveCitation(Citation edit)
this.commitCitation(edit);
}

public void saveCitationCollectionOrder(CitationCollectionOrder citationCollectionOrder)
{
this.commitCitationCollectionOrder(citationCollectionOrder);
}

public void saveCollection(CitationCollection collection)
{
this.commitCollection(collection);
Expand Down Expand Up @@ -349,6 +354,23 @@ else if(value instanceof String)
}
}

/* (non-Javadoc)
* @see org.sakaiproject.citation.impl.BaseCitationService.Storage#commitCitationCollectionOrder(org.sakaiproject.citation.api.CitationCollectionOrder)
*/
protected void commitCitationCollectionOrder(CitationCollectionOrder citationCollectionOrder)
{
String orderStatement = "insert into " + m_collectionOrderTableName + " (COLLECTION_ID, CITATION_ID, LOCATION, SECTION_TYPE, VALUE) VALUES(?,?,?,?,?)";

Object[] orderFields = new Object[5];
orderFields [0] = citationCollectionOrder.getCollectionId();
orderFields [1] = citationCollectionOrder.getCitationid();
orderFields [2] = citationCollectionOrder.getLocation();
orderFields [3] = citationCollectionOrder.getSectiontype();
orderFields [4] = citationCollectionOrder.getValue();

m_sqlService.dbWrite(orderStatement, orderFields);
}

/* (non-Javadoc)
* @see org.sakaiproject.citation.impl.BaseCitationService.Storage#commitCitationCollectionOrder(org.sakaiproject.citation.api.CitationCollectionOrder)
*/
Expand Down Expand Up @@ -1218,6 +1240,9 @@ private void getCitationCollectionOrders(String collectionId, BasicCitationColle
citation.setPosition(Integer.parseInt((String) orderTriple.getValue()));
edit.add(citation);
}

List<CitationCollectionOrder> citationCollectionOrders = getNestedCollectionAsList(collectionId);
edit.setNestedCitationCollectionOrders(citationCollectionOrders);
}

private BasicCitationCollection getBasicCitationCollection(String collectionId) {
Expand Down Expand Up @@ -1754,14 +1779,14 @@ public Object readSqlResultRecord(ResultSet result)
collectionId = result.getString(1);
citationId = result.getString(2);
location = result.getInt(3);
sectionType = CitationCollectionOrder.SectionType.valueOf(result.getString(4));
sectionType = result.getString(4)==null ? null : CitationCollectionOrder.SectionType.valueOf(result.getString(4));
value = result.getString(5);

citationCollectionOrder = new CitationCollectionOrder(collectionId, citationId, location, sectionType, value);
}
catch (SQLException e)
{
M_log.warn("TripleReader: problem reading CitationCollectionOrder from result: collectionId(" + collectionId + ") location(" + location
M_log.warn("CitationCollectionOrderReader: problem reading CitationCollectionOrder from result: collectionId(" + collectionId + ") location(" + location
+ ") sectionType(" + sectionType + ") value(" + value + ")");
return null;
}
Expand Down
Loading

0 comments on commit f2ff8f1

Please sign in to comment.