Updates to enable deletion of object individuals for vcard editing
This commit is contained in:
parent
5d19e746e1
commit
769b53e919
4 changed files with 42 additions and 10 deletions
|
@ -167,21 +167,21 @@ public class DeletePropertyController extends FreemarkerHttpServlet {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//process object property
|
||||
private void processObjectProperty(VitroRequest vreq) {
|
||||
ObjectProperty prop = EditConfigurationUtils.getObjectProperty(vreq);
|
||||
|
||||
//if this property is true, it means the object needs to be deleted along with statement
|
||||
if(prop.getStubObjectRelation())
|
||||
//while the second test is to see if a different object uri (i.e. not the direct objet of the predicate)
|
||||
//needs to be deleted
|
||||
if(prop.getStubObjectRelation() || hasDeleteObjectUri(vreq))
|
||||
{
|
||||
deleteObjectIndividual(vreq);
|
||||
}
|
||||
|
||||
deleteObjectPropertyStatement(vreq);
|
||||
if(!hasDeleteObjectUri(vreq)) {
|
||||
deleteObjectPropertyStatement(vreq);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,7 @@ public class DeletePropertyController extends FreemarkerHttpServlet {
|
|||
wdf.getPropertyInstanceDao().deleteObjectPropertyStatement(subjectUri, predicateUri, objectUri);
|
||||
}
|
||||
|
||||
private Individual getObjectIndividualForStubRelation(VitroRequest vreq, String objectUri) {
|
||||
private Individual getObjectIndividualForDeletion(VitroRequest vreq, String objectUri) {
|
||||
|
||||
Individual object = EditConfigurationUtils.getIndividual(vreq, objectUri);
|
||||
if(object == null) {
|
||||
|
@ -208,9 +208,13 @@ public class DeletePropertyController extends FreemarkerHttpServlet {
|
|||
|
||||
private void deleteObjectIndividual(VitroRequest vreq) {
|
||||
String objectUri = EditConfigurationUtils.getObjectUri(vreq);
|
||||
Individual object = getObjectIndividualForStubRelation(vreq, objectUri);
|
||||
if(hasDeleteObjectUri(vreq)) {
|
||||
//if a different individual needs to be deleted, get that uri instead
|
||||
objectUri = getDeleteObjectUri(vreq);
|
||||
}
|
||||
Individual object = getObjectIndividualForDeletion(vreq, objectUri);
|
||||
if(object != null) {
|
||||
log.warn("Deleting individual " + object.getName() + "since property has been set to force range object deletion");
|
||||
log.warn("Deleting individual " + object.getName() + "since property has been set to force range object deletion or has been set to delete a specific object");
|
||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||
wdf.getIndividualDao().deleteIndividual(object);
|
||||
} else {
|
||||
|
@ -218,6 +222,16 @@ public class DeletePropertyController extends FreemarkerHttpServlet {
|
|||
log.error("could not find object as request attribute or in model " + objectUri);
|
||||
}
|
||||
}
|
||||
|
||||
//This checks if the object uri is not the individual to be deleted but another individual connected
|
||||
private String getDeleteObjectUri(VitroRequest vreq) {
|
||||
return (String) vreq.getParameter("deleteObjectUri");
|
||||
}
|
||||
|
||||
private boolean hasDeleteObjectUri(VitroRequest vreq) {
|
||||
String deleteObjectUri = getDeleteObjectUri(vreq);
|
||||
return (deleteObjectUri != null && !deleteObjectUri.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -491,6 +491,10 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
|
|||
return getDataLiteralValuesFromParameter();
|
||||
}
|
||||
|
||||
//Get a custom object uri for deletion if one exists, i.e. not the object uri for the property
|
||||
public String getCustomDeleteObjectUri() {
|
||||
return (String) vreq.getParameter("deleteObjectUri");
|
||||
}
|
||||
//Used for deletion in case there's a specific template to be employed
|
||||
public String getDeleteTemplate() {
|
||||
String templateName = vreq.getParameter("templateName");
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<input type="hidden" name="predicateUri" value="${editConfiguration.predicateUri}" role="input" />
|
||||
<input type="hidden" name="domainUri" value="${editConfiguration.domainUri}" role="input" />
|
||||
<input type="hidden" name="rangeUri" value="${editConfiguration.rangeUri}" role="input" />
|
||||
|
||||
<input type="hidden" name="deleteObjectUri" value="${editConfiguration.customDeleteObjectUri}" />
|
||||
<#if editConfiguration.dataProperty = true>
|
||||
<input type="hidden" name="datapropKey" value="${editConfiguration.datapropKey}" role="input" />
|
||||
<input type="hidden" name="vitroNsProp" value="${editConfiguration.vitroNsProperty}" role="input" />
|
||||
|
|
|
@ -205,6 +205,20 @@ name will be used as the label. -->
|
|||
<#macro deleteLink propertyLocalName propertyName statement>
|
||||
<#local url = statement.deleteUrl>
|
||||
<#if url?has_content>
|
||||
<#--We need to specify the actual object to be deleted as it is different from the object uri-->
|
||||
<#if propertyLocalName?contains("ARG_2000028")>
|
||||
<#if propertyName?contains("mailing address")>
|
||||
<#local url = url + "&deleteObjectUri=" + "${statement.address!}">
|
||||
<#elseif propertyName?contains("phone") || propertyName?contains("fax")>
|
||||
<#local url = url + "&deleteObjectUri=" + "${statement.phone!}">
|
||||
<#elseif propertyName?contains("primary email") || propertyName?contains("additional emails")>
|
||||
<#local url = url + "&deleteObjectUri=" + "${statement.email!}">
|
||||
<#elseif propertyName?contains("full name")>
|
||||
<#local url = url + "&deleteObjectUri=" + "${statement.fullName!}">
|
||||
<#elseif propertyName?contains("preferred title")>
|
||||
<#local url = url + "&deleteObjectUri=" + "${statement.title!}">
|
||||
</#if>
|
||||
</#if>
|
||||
<@showDeleteLink propertyLocalName url />
|
||||
</#if>
|
||||
</#macro>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue