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 dissimilar 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_DISSIMILAR_PHOTOLIST]" type="GET" query="" body_uri=""}
032 */
033@XmlRootElement(name=Definitions.ELEMENT_DISSIMILAR_PHOTOLIST)  // override root element name
034@XmlAccessorType(XmlAccessType.NONE)
035public class DissimilarPhotoList extends PhotoList{
036  private static final Logger LOGGER = Logger.getLogger(DissimilarPhotoList.class);
037  
038  @Override
039  protected boolean isValid() {
040    if(isEmpty()){
041      return false;
042    }
043    LOGGER.debug("Using "+DissimilarPhotoList.class.toString()+" for validation of a photo list.");
044    for(Photo p : getPhotos()){
045      if(StringUtils.isBlank(p.getGUID())){
046        return false;
047      }
048    }
049    return true;
050  }
051}