NIHVIVO-3396 removed code related to individualSortField
This commit is contained in:
parent
a09a99c597
commit
eee41106a1
8 changed files with 36 additions and 146 deletions
|
@ -93,8 +93,6 @@ public interface Individual extends ResourceBean, Comparable<Individual> {
|
|||
void sortForDisplay();
|
||||
|
||||
JSONObject toJSON() throws JSONException;
|
||||
|
||||
Object getField(String fieldName) throws NoSuchMethodException;
|
||||
|
||||
Float getSearchBoost();
|
||||
void setSearchBoost( Float boost );
|
||||
|
|
|
@ -319,33 +319,6 @@ public class IndividualImpl extends BaseResourceBean implements Individual, Comp
|
|||
JSONObject jsonObj = new JSONObject(this, INCLUDED_IN_JSON);
|
||||
return jsonObj;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param fieldName- expected to be the field name in the format
|
||||
* @return
|
||||
* @throws NoSuchMethodException
|
||||
*/
|
||||
public Object getField(String fieldName) throws NoSuchMethodException{
|
||||
if( fieldName == null || fieldName.length() == 0) return null;
|
||||
|
||||
if( "name".equalsIgnoreCase(fieldName) )
|
||||
return getName();
|
||||
|
||||
//not one of the more common ones, try reflection
|
||||
|
||||
//capitalize first letter
|
||||
String methodName = "get" + fieldName.substring(0,1).toUpperCase()
|
||||
+ fieldName.substring(1,fieldName.length());
|
||||
|
||||
Class cls = this.getClass();
|
||||
try {
|
||||
Method meth = cls.getMethod(methodName, (Class[]) null);
|
||||
return meth.invoke(this,(Object[])null);
|
||||
} catch (Exception e) { }
|
||||
//should never get here
|
||||
throw new NoSuchMethodException("Entity.getField() attempt to use a method called "
|
||||
+ methodName +"() for field " + fieldName + " but the method doesn't exist.");
|
||||
}
|
||||
|
||||
public int compareTo(Individual o2) {
|
||||
Collator collator = Collator.getInstance();
|
||||
|
|
|
@ -289,12 +289,6 @@ public class ObjectProperty extends Property implements Comparable<ObjectPropert
|
|||
public void setDomainEntitySortDirection(String domainEntitySortDirection) {
|
||||
this.domainEntitySortDirection = domainEntitySortDirection;
|
||||
}
|
||||
public String getDomainEntitySortField() {
|
||||
return domainEntitySortField;
|
||||
}
|
||||
public void setDomainEntitySortField(String domainEntitySortField) {
|
||||
this.domainEntitySortField = domainEntitySortField;
|
||||
}
|
||||
public String getObjectIndividualSortPropertyURI() {
|
||||
return this.objectIndividualSortPropertyURI;
|
||||
}
|
||||
|
@ -337,12 +331,6 @@ public class ObjectProperty extends Property implements Comparable<ObjectPropert
|
|||
public void setRangeEntitySortDirection(String rangeEntitySortDirection) {
|
||||
this.rangeEntitySortDirection = rangeEntitySortDirection;
|
||||
}
|
||||
public String getRangeEntitySortField() {
|
||||
return rangeEntitySortField;
|
||||
}
|
||||
public void setRangeEntitySortField(String rangeEntitySortField) {
|
||||
this.rangeEntitySortField = rangeEntitySortField;
|
||||
}
|
||||
public boolean getSelectFromExisting() {
|
||||
return selectFromExisting;
|
||||
}
|
||||
|
@ -389,79 +377,65 @@ public class ObjectProperty extends Property implements Comparable<ObjectPropert
|
|||
tier2 = (tier2 == null) ? 0 : tier2;
|
||||
return tier1 - tier2;
|
||||
}
|
||||
}
|
||||
|
||||
private Collator collator = Collator.getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the object property statements taking into account the sort order.
|
||||
*/
|
||||
public static List<ObjectPropertyStatement> sortObjectPropertyStatementsForDisplay(ObjectProperty prop, List objPropStmtsList) {
|
||||
if (objPropStmtsList==null) {
|
||||
log.error("incoming object property statement list is null; returning null");
|
||||
public static List<ObjectPropertyStatement> sortObjectPropertyStatementsForDisplay(
|
||||
ObjectProperty prop, List objPropStmtsList) {
|
||||
|
||||
if (objPropStmtsList == null) {
|
||||
log.error("incoming object property statement list is null; " +
|
||||
"returning null");
|
||||
return null;
|
||||
}
|
||||
if (objPropStmtsList.size()<2) { // no need to sort
|
||||
if (objPropStmtsList.size() < 2) { // no need to sort
|
||||
return objPropStmtsList;
|
||||
}
|
||||
String tmpDirection = prop.getDomainEntitySortDirection(); //valid values are "desc" and "asc", anything else will default to ascending
|
||||
final boolean direction = !"desc".equalsIgnoreCase(tmpDirection);
|
||||
|
||||
String tmpDirection = prop.getDomainEntitySortDirection();
|
||||
// Valid values are "desc" and "asc";
|
||||
// anything else will default to ascending.
|
||||
final boolean ascending = !"desc".equalsIgnoreCase(tmpDirection);
|
||||
|
||||
String objIndivSortPropURI=prop.getObjectIndividualSortPropertyURI();
|
||||
if (prop.getObjectIndividualSortPropertyURI() == null || prop.getObjectIndividualSortPropertyURI().length()==0) {
|
||||
String tmpField = prop.getDomainEntitySortField();
|
||||
log.debug("objectIndividualSortPropertyURI is null or blank so sorting by field "+tmpField);
|
||||
if( tmpField == null || tmpField.length() == 0) {
|
||||
tmpField = "name";
|
||||
}
|
||||
final String field = tmpField;
|
||||
String objIndivSortPropURI = prop.getObjectIndividualSortPropertyURI();
|
||||
if (prop.getObjectIndividualSortPropertyURI() == null
|
||||
|| prop.getObjectIndividualSortPropertyURI().length() == 0) {
|
||||
log.debug("objectIndividualSortPropertyURI is null or blank " +
|
||||
"so sorting by name ");
|
||||
|
||||
Comparator fieldComp = new Comparator() {
|
||||
final String cField= field;
|
||||
final boolean cAsc = direction;
|
||||
|
||||
|
||||
public final int compare(Object o1, Object o2) {
|
||||
ObjectPropertyStatement e2e1= (ObjectPropertyStatement)o1, e2e2=(ObjectPropertyStatement)o2;
|
||||
ObjectPropertyStatement e2e1 = (ObjectPropertyStatement) o1,
|
||||
e2e2 = (ObjectPropertyStatement) o2;
|
||||
Individual e1 , e2;
|
||||
e1 = e2e1 != null ? e2e1.getObject():null;
|
||||
e2 = e2e2 != null ? e2e2.getObject():null;
|
||||
|
||||
Object val1 = null, val2 = null;
|
||||
if( e1 != null ) {
|
||||
try {
|
||||
val1 = e1.getField(cField);
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
val1 = e1.getName();
|
||||
} else {
|
||||
log.debug( "PropertyWebapp.sortObjectPropertiesForDisplay() passed object property statement with no range entity.");
|
||||
log.debug( "PropertyWebapp.sortObjectPropertiesForDisplay() " +
|
||||
"passed object property statement with no range entity.");
|
||||
}
|
||||
if( e2 != null ) {
|
||||
try {
|
||||
val2 = e2.getField(cField);
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
val2 = e2.getName();
|
||||
} else {
|
||||
log.debug( "PropertyWebapp.sortObjectPropertyStatementsForDisplay passed object property statement with no range entity.");
|
||||
log.debug( "PropertyWebapp.sortObjectPropertyStatementsForDisplay " +
|
||||
"passed object property statement with no range entity.");
|
||||
}
|
||||
int rv = 0;
|
||||
try {
|
||||
if( val1 instanceof String ) {
|
||||
|
||||
if (val1 == null && val2 == null) {
|
||||
rv = 0;
|
||||
} else if (val1 == null) {
|
||||
rv = 1;
|
||||
} else if (val2 == null) {
|
||||
if (val2 == null) {
|
||||
rv = -1;
|
||||
} else {
|
||||
|
||||
Collator collator = Collator.getInstance();
|
||||
rv = collator.compare( ((String)val1) , ((String)val2) );
|
||||
//rv = ((String)val1).compareTo((String)val2);
|
||||
rv = collator.compare( ((String)val1) , ((String)val2) );
|
||||
}
|
||||
|
||||
} else if( val1 instanceof Date ) {
|
||||
DateTime dt1 = new DateTime((Date)val1);
|
||||
DateTime dt2 = new DateTime((Date)val2);
|
||||
|
@ -473,7 +447,7 @@ public class ObjectProperty extends Property implements Comparable<ObjectPropert
|
|||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if( cAsc ) {
|
||||
if( ascending ) {
|
||||
return rv;
|
||||
} else {
|
||||
return rv * -1;
|
||||
|
@ -487,11 +461,9 @@ public class ObjectProperty extends Property implements Comparable<ObjectPropert
|
|||
}
|
||||
} else { // sort by specified range entity data property value instead of a property having a get() method in Individual.java
|
||||
log.debug("using data property "+prop.getObjectIndividualSortPropertyURI()+" to sort related entities");
|
||||
final boolean compDirection = direction;
|
||||
final String objIndSortPropURI = prop.getObjectIndividualSortPropertyURI();
|
||||
Comparator dpComp = new Comparator() {
|
||||
final String cDatapropURI = objIndSortPropURI;
|
||||
final boolean cAscending = compDirection;
|
||||
|
||||
public final int compare(Object o1, Object o2){
|
||||
ObjectPropertyStatement e2e1= (ObjectPropertyStatement)o1, e2e2=(ObjectPropertyStatement)o2;
|
||||
|
@ -567,7 +539,7 @@ public class ObjectProperty extends Property implements Comparable<ObjectPropert
|
|||
}
|
||||
|
||||
|
||||
if ( !cAscending ) {
|
||||
if ( !ascending ) {
|
||||
rv = rv * -1;
|
||||
}
|
||||
|
||||
|
@ -582,14 +554,10 @@ public class ObjectProperty extends Property implements Comparable<ObjectPropert
|
|||
}
|
||||
};
|
||||
try {
|
||||
if (dpComp==null) {
|
||||
log.error("data property comparator is null; returning unsorted object property statements list");
|
||||
return objPropStmtsList;
|
||||
} else {
|
||||
Collections.sort(objPropStmtsList, dpComp);
|
||||
}
|
||||
Collections.sort(objPropStmtsList, dpComp);
|
||||
} catch (Exception e) {
|
||||
log.error("Exception sorting object property statements for object property "+prop.getURI());
|
||||
log.error("Exception sorting object property statements " +
|
||||
"for object property " + prop.getURI(), e);
|
||||
}
|
||||
}
|
||||
return objPropStmtsList;
|
||||
|
@ -619,7 +587,6 @@ public class ObjectProperty extends Property implements Comparable<ObjectPropert
|
|||
"domainDisplayTier: " + getDomainDisplayTier() + "\n\t" +
|
||||
"domainEntityId: " + getDomainEntityURI() + "\n\t" +
|
||||
"domainEntitySortDirection: " + getDomainEntitySortDirection() + "\n\t" +
|
||||
"domainEntitySortField: " + getDomainEntitySortField() + "\n\t" +
|
||||
"domainVClass: " + getDomainVClass() + "\n\t" +
|
||||
"domainClassId: " + getDomainVClassURI() + "\n\t" +
|
||||
"domainPublic: " + getDomainPublic() + "\n\t" +
|
||||
|
@ -628,7 +595,6 @@ public class ObjectProperty extends Property implements Comparable<ObjectPropert
|
|||
"rangeDisplayTier: " + getRangeDisplayTier() + "\n\t" +
|
||||
"rangeEntityId: " + getRangeEntityURI() + "\n\t" +
|
||||
"rangeEntitySortDirection: " + getRangeEntitySortDirection() + "\n\t" +
|
||||
"rangeEntitySortField: " + getRangeEntitySortField() + "\n\t" +
|
||||
"rangeVClass: " + getRangeVClass() + "\n\t" +
|
||||
"rangeClassId: " + getRangeVClassURI() + "\n\t" +
|
||||
"rangePublic: " + getRangePublic() + "\n\t" +
|
||||
|
|
|
@ -213,11 +213,6 @@ public class IndividualFiltering implements Individual {
|
|||
return _innerIndividual.getExternalIds();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getField(String fieldName) throws NoSuchMethodException {
|
||||
return _innerIndividual.getField(fieldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMainImageUri() {
|
||||
return _innerIndividual.getMainImageUri();
|
||||
|
|
|
@ -90,11 +90,6 @@ public class ObjectPropertyFiltering extends ObjectProperty {
|
|||
return innerObjectProperty.getDomainEntitySortDirection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDomainEntitySortField() {
|
||||
return innerObjectProperty.getDomainEntitySortField();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDomainEntityURI() {
|
||||
return innerObjectProperty.getDomainEntityURI();
|
||||
|
@ -227,11 +222,6 @@ public class ObjectPropertyFiltering extends ObjectProperty {
|
|||
return innerObjectProperty.getRangeEntitySortDirection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRangeEntitySortField() {
|
||||
return innerObjectProperty.getRangeEntitySortField();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRangeEntityURI() {
|
||||
return innerObjectProperty.getRangeEntityURI();
|
||||
|
@ -318,11 +308,6 @@ public class ObjectPropertyFiltering extends ObjectProperty {
|
|||
.setDomainEntitySortDirection(domainEntitySortDirection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDomainEntitySortField(String domainEntitySortField) {
|
||||
innerObjectProperty.setDomainEntitySortField(domainEntitySortField);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDomainEntityURI(String domainEntityURI) {
|
||||
innerObjectProperty.setDomainEntityURI(domainEntityURI);
|
||||
|
@ -464,11 +449,6 @@ public class ObjectPropertyFiltering extends ObjectProperty {
|
|||
.setRangeEntitySortDirection(rangeEntitySortDirection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRangeEntitySortField(String rangeEntitySortField) {
|
||||
innerObjectProperty.setRangeEntitySortField(rangeEntitySortField);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRangeEntityURI(String rangeEntityURI) {
|
||||
innerObjectProperty.setRangeEntityURI(rangeEntityURI);
|
||||
|
|
|
@ -160,8 +160,6 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
|||
p.setRangeDisplayTier(getPropertyNonNegativeIntegerValue(invOp,DISPLAY_RANK_ANNOT));
|
||||
p.setDomainDisplayLimit(getPropertyNonNegativeIntValue(op,DISPLAY_LIMIT));
|
||||
p.setRangeDisplayLimit(getPropertyNonNegativeIntValue(invOp,DISPLAY_LIMIT));
|
||||
p.setDomainEntitySortField(getPropertyStringValue(op,PROPERTY_ENTITYSORTFIELD));
|
||||
p.setRangeEntitySortField(getPropertyStringValue(invOp,PROPERTY_ENTITYSORTFIELD));
|
||||
RDFNode objectIndividualSortPropertyNode = op.getPropertyValue(PROPERTY_OBJECTINDIVIDUALSORTPROPERTY);
|
||||
if (objectIndividualSortPropertyNode instanceof Resource) {
|
||||
p.setObjectIndividualSortPropertyURI( ((Resource)objectIndividualSortPropertyNode).getURI() );
|
||||
|
@ -532,13 +530,11 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
|||
updatePropertyStringValue(p,DESCRIPTION_ANNOT,prop.getDescription(),getOntModel());
|
||||
updatePropertyStringValue(p,PUBLIC_DESCRIPTION_ANNOT,prop.getPublicDescription(),getOntModel());
|
||||
updatePropertyNonNegativeIntegerValue(p,DISPLAY_LIMIT,prop.getDomainDisplayLimitInteger(),getOntModel());
|
||||
updatePropertyStringValue(p,PROPERTY_ENTITYSORTFIELD,prop.getDomainEntitySortField(),getOntModel());
|
||||
updatePropertyStringValue(p,PROPERTY_ENTITYSORTDIRECTION,prop.getDomainEntitySortDirection(),getOntModel());
|
||||
if (inv != null) {
|
||||
updatePropertyStringValue(inv,EXAMPLE_ANNOT,prop.getExample(),getOntModel());
|
||||
updatePropertyStringValue(inv,DESCRIPTION_ANNOT,prop.getDescription(),getOntModel());
|
||||
updatePropertyNonNegativeIntegerValue(inv,DISPLAY_LIMIT,prop.getRangeDisplayLimitInteger(),getOntModel());
|
||||
updatePropertyStringValue(inv,PROPERTY_ENTITYSORTFIELD,prop.getRangeEntitySortField(),getOntModel());
|
||||
updatePropertyStringValue(inv,PROPERTY_ENTITYSORTDIRECTION,prop.getRangeEntitySortDirection(),getOntModel());
|
||||
}
|
||||
|
||||
|
|
|
@ -405,11 +405,6 @@ public class IndividualStub implements Individual {
|
|||
throw new RuntimeException("Individual.toJSON() not implemented.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getField(String fieldName) throws NoSuchMethodException {
|
||||
throw new RuntimeException("Individual.getField() not implemented.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float getSearchBoost() {
|
||||
throw new RuntimeException(
|
||||
|
|
|
@ -153,14 +153,7 @@
|
|||
</tr>
|
||||
<tr class="editformcell">
|
||||
<td valign="bottom" colspan="2">
|
||||
<em>Optional: <strong>sort related individuals</strong> by<br />
|
||||
(default is sort by name)</em><br/>
|
||||
<input name="DomainEntitySortField" value="<form:value name="DomainEntitySortField"/>" />
|
||||
<c:set var="DomainEntitySortFieldError"><form:error name="DomainEntitySortField"/></c:set>
|
||||
<c:if test="${!empty DomainEntitySortFieldError}">
|
||||
<span class="notice"><c:out value="${DomainEntitySortFieldError}"/></span>
|
||||
</c:if>
|
||||
</td>
|
||||
</td>
|
||||
<td valign="bottom" colspan="1">
|
||||
<em>Optional: <strong>sort direction</strong><br />
|
||||
(blank for ascending, "desc" for descending)</em><br/>
|
||||
|
@ -276,13 +269,7 @@
|
|||
|
||||
<tr class="editformcell">
|
||||
<td valign="bottom" colspan="2">
|
||||
<em>Optional: <strong>sort related object individuals of inverse property</strong> by<br />
|
||||
(default is sort by name)</em><br/>
|
||||
<input name="RangeEntitySortField" value="<form:value name="RangeEntitySortField"/>" />
|
||||
<c:set var="RangeEntitySortFieldError"><form:error name="RangeEntitySortField"/></c:set>
|
||||
<c:if test="${!empty RangeEntitySortFieldError}">
|
||||
<span class="notice"><c:out value="${RangeEntitySortFieldError}"/></span>
|
||||
</c:if>
|
||||
|
||||
</td>
|
||||
<td valign="bottom" colspan="1">
|
||||
<em>Optional: <strong>inverse sort direction</strong><br />
|
||||
|
|
Loading…
Add table
Reference in a new issue