Author: bleny Date: 2014-02-26 11:17:06 +0100 (Wed, 26 Feb 2014) New Revision: 1688 Url: http://codelutin.com/projects/wao/repository/revisions/1688 Log: add some guava functions about entities Added: trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/Boats.java trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/Companies.java trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactStateMotives.java trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/FishingZones.java trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ObsDebCodes.java trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRows.java trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/TerrestrialLocations.java trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/WaoUsers.java Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java =================================================================== --- trunk/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java 2014-02-25 16:41:01 UTC (rev 1687) +++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java 2014-02-26 10:17:06 UTC (rev 1688) @@ -1,8 +1,11 @@ package fr.ifremer.wao; +import fr.ifremer.wao.entity.ObsProgram; + import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.regex.Pattern; public class WaoUtils { @@ -34,4 +37,8 @@ DateFormat dateFormat = new SimpleDateFormat(pattern); return dateFormat.format(date); } + + public static Pattern getSampleRowCodePattern(ObsProgram obsProgram) { + return Pattern.compile("^(\\d{4})_" + obsProgram.getShortCode() + "(\\d{4})$"); + } } Added: trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/Boats.java =================================================================== --- trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/Boats.java (rev 0) +++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/Boats.java 2014-02-26 10:17:06 UTC (rev 1688) @@ -0,0 +1,19 @@ +package fr.ifremer.wao.entity; + +import com.google.common.base.Function; + +public class Boats { + + public static Function<Boat, Integer> getImmatriculation() { + return new GetImmatriculation(); + } + + protected static class GetImmatriculation implements Function<Boat, Integer> { + + @Override + public Integer apply(Boat input) { + Integer immatriculation = input.getImmatriculation(); + return immatriculation; + } + } +} Added: trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/Companies.java =================================================================== --- trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/Companies.java (rev 0) +++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/Companies.java 2014-02-26 10:17:06 UTC (rev 1688) @@ -0,0 +1,18 @@ +package fr.ifremer.wao.entity; + +import com.google.common.base.Function; + +public class Companies { + + public static Function<Company, String> getName() { + return new GetName(); + } + + protected static class GetName implements Function<Company, String> { + + @Override + public String apply(Company input) { + return input.getName(); + } + } +} Added: trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactStateMotives.java =================================================================== --- trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactStateMotives.java (rev 0) +++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactStateMotives.java 2014-02-26 10:17:06 UTC (rev 1688) @@ -0,0 +1,18 @@ +package fr.ifremer.wao.entity; + +import com.google.common.base.Function; + +public class ContactStateMotives { + + public static Function<ContactStateMotif, String> getCode() { + return new GetCode(); + } + + protected static class GetCode implements Function<ContactStateMotif, String> { + + @Override + public String apply(ContactStateMotif input) { + return input.getCode(); + } + } +} Added: trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/FishingZones.java =================================================================== --- trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/FishingZones.java (rev 0) +++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/FishingZones.java 2014-02-26 10:17:06 UTC (rev 1688) @@ -0,0 +1,19 @@ +package fr.ifremer.wao.entity; + +import com.google.common.base.Function; + +public class FishingZones { + + public static Function<FishingZone, String> getDistrictCode() { + return new GetDistrictCode(); + } + + protected static class GetDistrictCode implements Function<FishingZone, String> { + + @Override + public String apply(FishingZone input) { + return input.getDistrictCode(); + } + } + +} Added: trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ObsDebCodes.java =================================================================== --- trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ObsDebCodes.java (rev 0) +++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ObsDebCodes.java 2014-02-26 10:17:06 UTC (rev 1688) @@ -0,0 +1,19 @@ +package fr.ifremer.wao.entity; + +import com.google.common.base.Function; + +public class ObsDebCodes { + + public static Function<ObsDebCode, String> getCode() { + return new GetCode(); + } + + protected static class GetCode implements Function<ObsDebCode, String> { + + @Override + public String apply(ObsDebCode input) { + return input.getCode(); + } + } + +} Added: trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRows.java =================================================================== --- trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRows.java (rev 0) +++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRows.java 2014-02-26 10:17:06 UTC (rev 1688) @@ -0,0 +1,18 @@ +package fr.ifremer.wao.entity; + +import com.google.common.base.Function; + +public class SampleRows { + + public static Function<SampleRow, String> getCode() { + return new GetCode(); + } + + protected static class GetCode implements Function<SampleRow, String> { + + @Override + public String apply(SampleRow input) { + return input.getCode(); + } + } +} Added: trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/TerrestrialLocations.java =================================================================== --- trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/TerrestrialLocations.java (rev 0) +++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/TerrestrialLocations.java 2014-02-26 10:17:06 UTC (rev 1688) @@ -0,0 +1,42 @@ +package fr.ifremer.wao.entity; + +import com.google.common.base.Function; + +public class TerrestrialLocations { + + public static Function<TerrestrialLocation, String> getDistrictCode() { + return new GetDistrictCode(); + } + + public static Function<TerrestrialLocation, String> getCode() { + return new GetCode(); + } + + public static Function<TerrestrialLocation, String> getRegionIfremerCode() { + return new GetRegionIfremerCode(); + } + + protected static class GetDistrictCode implements Function<TerrestrialLocation, String> { + + @Override + public String apply(TerrestrialLocation input) { + return input.getDistrictCode(); + } + } + + protected static class GetCode implements Function<TerrestrialLocation, String> { + + @Override + public String apply(TerrestrialLocation input) { + return input.getCode(); + } + } + + protected static class GetRegionIfremerCode implements Function<TerrestrialLocation, String> { + + @Override + public String apply(TerrestrialLocation input) { + return input.getRegionIfremerCode(); + } + } +} Added: trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/WaoUsers.java =================================================================== --- trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/WaoUsers.java (rev 0) +++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/WaoUsers.java 2014-02-26 10:17:06 UTC (rev 1688) @@ -0,0 +1,18 @@ +package fr.ifremer.wao.entity; + +import com.google.common.base.Function; + +public class WaoUsers { + + public static Function<WaoUser, String> getLogin() { + return new GetLogin(); + } + + protected static class GetLogin implements Function<WaoUser, String> { + + @Override + public String apply(WaoUser input) { + return input.getLogin(); + } + } +}