001/**
002 * Copyright 2014 Tampere University of Technology, Pori Department
003 * 
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 * 
008 *   http://www.apache.org/licenses/LICENSE-2.0
009 * 
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package service.tut.pori.contentanalysis;
017
018import javax.xml.bind.annotation.XmlAccessType;
019import javax.xml.bind.annotation.XmlAccessorType;
020import javax.xml.bind.annotation.XmlRootElement;
021
022import org.apache.commons.lang3.StringUtils;
023import org.apache.log4j.Logger;
024
025
026/**
027 * A special photo list used to list similar photos.
028 * 
029 * <h3>XML Example</h3>
030 * 
031 * {@doc.restlet service="[service.tut.pori.contentanalysis.reference.Definitions#SERVICE_CA_REFERENCE_EXAMPLE]" method="[service.tut.pori.contentanalysis.Definitions#ELEMENT_SIMILAR_PHOTOLIST]" type="GET" query="" body_uri=""}
032 *  
033 */
034@XmlRootElement(name=Definitions.ELEMENT_SIMILAR_PHOTOLIST) // override root element name
035@XmlAccessorType(XmlAccessType.NONE)
036public class SimilarPhotoList extends PhotoList{
037  private static final Logger LOGGER = Logger.getLogger(SimilarPhotoList.class);
038  
039  @Override
040  protected boolean isValid() {
041    if(isEmpty()){
042      return false;
043    }
044    LOGGER.debug("Using "+SimilarPhotoList.class.toString()+" for validation of a photo list.");
045    for(Photo p : getPhotos()){
046      if(StringUtils.isBlank(p.getGUID())){
047        return false;
048      }
049    }
050    return true;
051  }
052}