teichmann@5835: package org.dive4elements.river.client.client.ui; felix@1298: felix@1298: import com.smartgwt.client.widgets.grid.ListGridRecord; christian@4184: teichmann@5835: import org.dive4elements.river.client.shared.model.Recommendation; felix@1298: felix@1298: felix@1298: /** felix@1298: * Two strings to be displayed in a GridList, derived from two felix@1298: * Recommendations. felix@1298: */ felix@1298: public class RecommendationPairRecord extends ListGridRecord { felix@1298: felix@1298: /** First attribute-name for StringPairRecord. */ felix@1298: protected static final String ATTRIBUTE_FIRST = "first"; sascha@2905: felix@1298: /** Second attribute-name for StringPairRecord. */ felix@1298: protected static final String ATTRIBUTE_SECOND = "second"; felix@1299: felix@1299: /** The "first" recommendation (typically the minuend). */ felix@1298: Recommendation first; felix@1299: felix@1299: /** The "second" recommendation (typically the subtrahend). */ felix@1298: Recommendation second; felix@1299: felix@1304: /** felix@1304: * Whether the RecommendationPairRecord was restored from data and thus felix@1304: * already loaded (usually cloned) in an ArtifactCollection or not. felix@1304: */ felix@1304: boolean alreadyLoaded; felix@1304: felix@1298: felix@1333: /** Trivial, blocked constructor. */ christian@4184: @SuppressWarnings("unused") felix@1333: private RecommendationPairRecord() { felix@1298: } felix@1298: felix@1298: felix@1299: /** felix@1299: * Create a new RecommendationPairRecord. felix@1299: * felix@1352: * @param first The first recommendation (typically the minuend). felix@1352: * @param second The second recommendation (typically the subtrahend). felix@1299: */ felix@1299: public RecommendationPairRecord( felix@1298: Recommendation first, felix@1298: Recommendation second) felix@1298: { felix@1352: setFirst(first); felix@1352: setSecond(second); felix@1304: alreadyLoaded = false; felix@1298: } felix@1298: felix@1298: felix@1299: /** felix@1299: * Sets the first recommendation with info (minuend). felix@1333: * @param first Recommendation to store. felix@1299: */ felix@1352: public void setFirst(Recommendation first) { felix@1298: this.first = first; felix@1352: setAttribute(ATTRIBUTE_FIRST, first.getDisplayName()); felix@1298: } felix@1298: felix@1298: felix@1299: /** felix@1299: * Sets the second recommendation with info (subtrahend). felix@1333: * @param second Recommendation to store. felix@1299: */ felix@1352: public void setSecond(Recommendation second) { felix@1298: this.second = second; felix@1352: setAttribute(ATTRIBUTE_SECOND, second.getDisplayName()); felix@1298: } felix@1298: felix@1298: felix@1299: /** felix@1299: * Get first recommendation (typically the minuend). felix@1299: * @return first recommendation (typically the minuend). felix@1299: */ felix@1298: public Recommendation getFirst() { felix@1298: return first; felix@1298: } felix@1298: felix@1299: felix@1299: /** felix@1299: * Get second recommendation (typically the subtrahend). felix@1299: * @return second recommendation (typically the subtrahend). felix@1299: */ felix@1298: public Recommendation getSecond() { felix@1298: return second; felix@1298: } felix@1298: felix@1298: felix@1299: /** felix@1299: * Get name of first recommendation (typically the minuend). felix@1299: * @return name of first recommendation (typically the minuend). felix@1299: */ felix@1298: public String getFirstName() { felix@1352: return first.getDisplayName(); felix@1298: } felix@1298: felix@1298: felix@1299: /** felix@1299: * Get name of second recommendation (typically the subtrahend). felix@1299: * @return name of second recommendation (typically the subtrahend). felix@1299: */ felix@1298: public String getSecondName() { felix@1352: return second.getDisplayName(); felix@1298: } felix@1304: felix@1304: felix@1304: /** felix@1304: * Sets whether or not the Recommendation is already loaded (in contrast felix@1304: * to not yet loaded). felix@1304: * @param isAlreadyLoaded new value. felix@1304: */ felix@1304: public void setIsAlreadyLoaded(boolean isAlreadyLoaded) { felix@1304: this.alreadyLoaded = isAlreadyLoaded; felix@1304: } felix@1304: felix@1304: felix@1304: /** felix@1304: * Whether or not this pair of recommendations is already laoded (usually felix@1304: * cloned) in an ArtifactCollection. felix@1304: * @return whether pair of recommendations is already loaded. felix@1304: */ felix@1304: public boolean isAlreadyLoaded() { felix@1304: return this.alreadyLoaded; felix@1304: } felix@1298: }