net.anotheria.asg.util.bean.LinkToMeBean Maven / Gradle / Ivy
package net.anotheria.asg.util.bean;
import net.anotheria.anodoc.data.NoSuchPropertyException;
import net.anotheria.asg.data.DataObject;
import net.anotheria.util.StringUtils;
/**
* A bean which represents an incoming link to a document (as a result of a query).
*
* @author lrosenberg
* @version $Id: $Id
*/
public class LinkToMeBean {
/**
* The type of the linking document.
*/
private String targetDocumentType;
/**
* The id of the linking document.
*/
private String targetDocumentId;
/**
* A description of the linking document.
*/
private String targetDocumentDescription;
/**
* The linking property.
*/
private String targetDocumentProperty;
/**
* A link for the edit tool for the linking document.
*/
private String targetDocumentLink;
/**
* Constructor for LinkToMeBean.
*/
public LinkToMeBean(){
}
/**
* Constructor for LinkToMeBean.
*
* @param doc a {@link net.anotheria.asg.data.DataObject} object.
* @param propertyName a {@link java.lang.String} object.
*/
public LinkToMeBean(DataObject doc, String propertyName){
targetDocumentType = doc.getDefinedName();
targetDocumentId = doc.getId();
targetDocumentLink = doc.getDefinedParentName().toLowerCase()+StringUtils.capitalize(doc.getDefinedName())+"Edit?ts="+System.currentTimeMillis()+"&pId="+doc.getId();
targetDocumentProperty = propertyName;
try{
targetDocumentDescription = ""+doc.getPropertyValue("name");
}catch(NoSuchPropertyException e){
}catch(RuntimeException e){
//temporarly, as long as VO objects are throwing exceptions of this type instead of something meaningful.
}
}
/**
* isDescriptionAvailable.
*
* @return a boolean.
*/
public boolean isDescriptionAvailable(){
return targetDocumentDescription!=null && targetDocumentDescription.length()>0;
}
/**
* Getter for the field targetDocumentType
.
*
* @return a {@link java.lang.String} object.
*/
public String getTargetDocumentType() {
return targetDocumentType;
}
/**
* Setter for the field targetDocumentType
.
*
* @param targetDocumentType a {@link java.lang.String} object.
*/
public void setTargetDocumentType(String targetDocumentType) {
this.targetDocumentType = targetDocumentType;
}
/**
* Getter for the field targetDocumentId
.
*
* @return a {@link java.lang.String} object.
*/
public String getTargetDocumentId() {
return targetDocumentId;
}
/**
* Setter for the field targetDocumentId
.
*
* @param targetDocumentId a {@link java.lang.String} object.
*/
public void setTargetDocumentId(String targetDocumentId) {
this.targetDocumentId = targetDocumentId;
}
/**
* Getter for the field targetDocumentDescription
.
*
* @return a {@link java.lang.String} object.
*/
public String getTargetDocumentDescription() {
return targetDocumentDescription;
}
/**
* Setter for the field targetDocumentDescription
.
*
* @param targetDocumentDescription a {@link java.lang.String} object.
*/
public void setTargetDocumentDescription(String targetDocumentDescription) {
this.targetDocumentDescription = targetDocumentDescription;
}
/**
* Getter for the field targetDocumentProperty
.
*
* @return a {@link java.lang.String} object.
*/
public String getTargetDocumentProperty() {
return targetDocumentProperty;
}
/**
* Setter for the field targetDocumentProperty
.
*
* @param targetDocumentProperty a {@link java.lang.String} object.
*/
public void setTargetDocumentProperty(String targetDocumentProperty) {
this.targetDocumentProperty = targetDocumentProperty;
}
/**
* Getter for the field targetDocumentLink
.
*
* @return a {@link java.lang.String} object.
*/
public String getTargetDocumentLink() {
return targetDocumentLink;
}
/**
* Setter for the field targetDocumentLink
.
*
* @param targetDocumentLink a {@link java.lang.String} object.
*/
public void setTargetDocumentLink(String targetDocumentLink) {
this.targetDocumentLink = targetDocumentLink;
}
}