001: //=============================================================================
002: //=== Copyright (C) 2001-2007 Food and Agriculture Organization of the
003: //=== United Nations (FAO-UN), United Nations World Food Programme (WFP)
004: //=== and United Nations Environment Programme (UNEP)
005: //===
006: //=== This program is free software; you can redistribute it and/or modify
007: //=== it under the terms of the GNU General Public License as published by
008: //=== the Free Software Foundation; either version 2 of the License, or (at
009: //=== your option) any later version.
010: //===
011: //=== This program is distributed in the hope that it will be useful, but
012: //=== WITHOUT ANY WARRANTY; without even the implied warranty of
013: //=== MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: //=== General Public License for more details.
015: //===
016: //=== You should have received a copy of the GNU General Public License
017: //=== along with this program; if not, write to the Free Software
018: //=== Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
019: //===
020: //=== Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2,
021: //=== Rome - Italy. email: geonetwork@osgeo.org
022: //==============================================================================
023:
024: package org.fao.geonet.kernel.harvest.harvester;
025:
026: import org.fao.geonet.util.ISODate;
027:
028: //=============================================================================
029:
030: public class RecordInfo {
031: //---------------------------------------------------------------------------
032: //---
033: //--- Constructor
034: //---
035: //---------------------------------------------------------------------------
036:
037: public RecordInfo(String uuid, String changeDate) {
038: this (uuid, changeDate, null, null);
039: }
040:
041: //---------------------------------------------------------------------------
042:
043: public RecordInfo(String uuid, String changeDate, String schema,
044: String source) {
045: if (changeDate == null) {
046: dateWasNull = true;
047: changeDate = new ISODate().toString();
048: }
049:
050: this .uuid = uuid;
051: this .changeDate = changeDate;
052: this .schema = schema;
053: this .source = source;
054: }
055:
056: //---------------------------------------------------------------------------
057: //---
058: //--- API methods
059: //---
060: //---------------------------------------------------------------------------
061:
062: public int hashCode() {
063: return uuid.hashCode();
064: }
065:
066: //---------------------------------------------------------------------------
067:
068: public boolean isMoreRecentThan(String localChangeDate) {
069: if (dateWasNull)
070: return true;
071:
072: ISODate remoteDate = new ISODate(changeDate);
073: ISODate localDate = new ISODate(localChangeDate);
074:
075: //--- accept if remote date is greater than local date
076:
077: return (remoteDate.sub(localDate) > 0);
078: }
079:
080: //---------------------------------------------------------------------------
081:
082: public boolean equals(Object o) {
083: if (o instanceof RecordInfo) {
084: RecordInfo ri = (RecordInfo) o;
085:
086: return uuid.equals(ri.uuid);
087: }
088:
089: return false;
090: }
091:
092: //---------------------------------------------------------------------------
093: //---
094: //--- Variables
095: //---
096: //---------------------------------------------------------------------------
097:
098: public String uuid;
099: public String changeDate;
100: public String schema;
101: public String source;
102:
103: private boolean dateWasNull;
104: }
105:
106: //=============================================================================
|