Search in sources :

Example 1 with Label

use of oms3.annotations.Label in project hortonmachine by TheHortonMachine.

the class HortonMachine method main.

public static void main(String[] args) throws IOException {
    HortonMachine hm = HortonMachine.getInstance();
    Set<Entry<String, Class<?>>> cls = hm.moduleName2Class.entrySet();
    for (Entry<String, Class<?>> cl : cls) {
        System.out.println(cl.getValue().getCanonicalName());
    }
    if (true)
        return;
    LinkedHashMap<String, List<ClassField>> moduleName2Fields = hm.moduleName2Fields;
    LinkedHashMap<String, Class<?>> moduleName2Class = hm.moduleName2Class;
    Set<Entry<String, List<ClassField>>> entrySet = moduleName2Fields.entrySet();
    for (Entry<String, List<ClassField>> entry : entrySet) {
        String moduleName = entry.getKey();
        StringBuilder sb = new StringBuilder();
        Class<?> moduleClass = moduleName2Class.get(moduleName);
        Description description = moduleClass.getAnnotation(Description.class);
        sb.append("public static final String " + moduleName.toUpperCase() + "_DESCRIPTION = \"" + description.value() + "\";\n");
        Documentation documentation = moduleClass.getAnnotation(Documentation.class);
        String doc;
        if (documentation == null) {
            doc = "";
        } else {
            doc = documentation.value();
        }
        sb.append("public static final String " + moduleName.toUpperCase() + "_DOCUMENTATION = \"" + doc + "\";\n");
        Keywords keywords = moduleClass.getAnnotation(Keywords.class);
        String k;
        if (keywords == null) {
            k = "";
        } else {
            k = keywords.value();
        }
        sb.append("public static final String " + moduleName.toUpperCase() + "_KEYWORDS = \"" + k + "\";\n");
        Label label = moduleClass.getAnnotation(Label.class);
        String lab;
        if (label == null) {
            lab = "";
        } else {
            lab = label.value();
        }
        sb.append("public static final String " + moduleName.toUpperCase() + "_LABEL = \"" + lab + "\";\n");
        Name name = moduleClass.getAnnotation(Name.class);
        String n;
        if (name == null) {
            n = "";
        } else {
            n = name.value();
        }
        sb.append("public static final String " + moduleName.toUpperCase() + "_NAME = \"" + n + "\";\n");
        Status status = moduleClass.getAnnotation(Status.class);
        // String st = "";
        // switch( status.value() ) {
        // case 5:
        // st = "EXPERIMENTAL";
        // break;
        // case 10:
        // st = "DRAFT";
        // break;
        // case 20:
        // st = "TESTED";
        // break;
        // case 30:
        // st = "VALIDATED";
        // break;
        // case 40:
        // st = "CERTIFIED";
        // break;
        // default:
        // st = "DRAFT";
        // break;
        // }
        sb.append("public static final int " + moduleName.toUpperCase() + "_STATUS = " + status.value() + ";\n");
        License license = moduleClass.getAnnotation(License.class);
        sb.append("public static final String " + moduleName.toUpperCase() + "_LICENSE = \"" + license.value() + "\";\n");
        Author author = moduleClass.getAnnotation(Author.class);
        String authorName = author.name();
        sb.append("public static final String " + moduleName.toUpperCase() + "_AUTHORNAMES = \"" + authorName + "\";\n");
        String authorContact = author.contact();
        sb.append("public static final String " + moduleName.toUpperCase() + "_AUTHORCONTACTS = \"" + authorContact + "\";\n");
        UI ui = moduleClass.getAnnotation(UI.class);
        if (ui != null) {
            sb.append("public static final String " + moduleName.toUpperCase() + "_UI = \"" + ui.value() + "\";\n");
        }
        List<ClassField> value = entry.getValue();
        for (ClassField classField : value) {
            String fieldName = classField.fieldName;
            if (fieldName.equals("pm")) {
                continue;
            }
            String fieldDescription = classField.fieldDescription;
            String str = "public static final String " + moduleName.toUpperCase() + "_" + fieldName + "_DESCRIPTION = \"" + fieldDescription + "\";\n";
            sb.append(str);
        }
        System.out.println(sb.toString());
        System.out.println();
    }
// for( String className : hm.allClasses ) {
// System.out.println(className);
// }
// for( String fieldName : hm.allFields ) {
// System.out.println(fieldName);
// }
}
Also used : Status(oms3.annotations.Status) Description(oms3.annotations.Description) Keywords(oms3.annotations.Keywords) Documentation(oms3.annotations.Documentation) Label(oms3.annotations.Label) License(oms3.annotations.License) Name(oms3.annotations.Name) Entry(java.util.Map.Entry) UI(oms3.annotations.UI) Author(oms3.annotations.Author) ArrayList(java.util.ArrayList) List(java.util.List) ClassField(org.hortonmachine.gears.libs.modules.ClassField)

Example 2 with Label

use of oms3.annotations.Label in project hortonmachine by TheHortonMachine.

the class OmsLW11_NetworkPropagator method process.

@Execute
public void process() throws Exception {
    /*
         * store the network points in a collection and map the Pfafstetter codes together with
         * the features ID in an  hashmap.
         */
    List<SimpleFeature> networkFeatures = FeatureUtilities.featureCollectionToList(inNetPoints);
    List<PfafstetterNumber> pfafstetterNumberList = new ArrayList<PfafstetterNumber>();
    HashMap<String, TreeMap<Integer, SimpleFeature>> pfafstetterNumber2FeaturesMap = new HashMap<String, TreeMap<Integer, SimpleFeature>>();
    // TODO add the check if the DBH field is available or not for the check on diameter!!
    for (SimpleFeature networkFeature : networkFeatures) {
        Object pfaffObject = networkFeature.getAttribute(NetworkChannel.PFAFNAME);
        if (pfaffObject instanceof String) {
            String pfaffString = (String) pfaffObject;
            PfafstetterNumber pfaf = new PfafstetterNumber(pfaffString);
            if (!pfafstetterNumberList.contains(pfaf)) {
                pfafstetterNumberList.add(pfaf);
            }
            TreeMap<Integer, SimpleFeature> featureTreeMap = pfafstetterNumber2FeaturesMap.get(pfaffString);
            if (featureTreeMap == null) {
                featureTreeMap = new TreeMap<Integer, SimpleFeature>();
                pfafstetterNumber2FeaturesMap.put(pfaffString, featureTreeMap);
            }
            Object linkidObj = networkFeature.getAttribute(FIELD_LINKID);
            if (linkidObj instanceof Integer) {
                Integer linkId = (Integer) linkidObj;
                featureTreeMap.put(linkId, networkFeature);
            }
        }
    }
    // sort the list of Pfafstetter to be ready to navigate the network
    Collections.sort(pfafstetterNumberList);
    /*
         * prepare the output feature collection as an extention of the input with 3 
         * additional attributes for critical sections
         */
    FeatureExtender ext = null;
    DefaultFeatureCollection outputFC = new DefaultFeatureCollection();
    /*
         * consider each link and navigate downstream each
         */
    double maxUpstreamHeight = -1;
    double maxUpstreamDiameter = -1;
    // create the variables to use in the cycle
    List<PfafstetterNumber> lastUpStreamPfafstetters = new ArrayList<PfafstetterNumber>();
    List<Double> lastUpStreamMaxHeights = new ArrayList<Double>();
    List<Double> lastUpStreamMaxDiameters = new ArrayList<Double>();
    List<String> lastUpStreamCriticSourceForLength = new ArrayList<String>();
    List<String> lastUpStreamCriticSourceForDiameter = new ArrayList<String>();
    /*
         * start the main cycle with the elaborations to identify the critical sections
         */
    pm.beginTask("Processing network...", pfafstetterNumberList.size());
    for (PfafstetterNumber pfafstetterNumber : pfafstetterNumberList) {
        TreeMap<Integer, SimpleFeature> featuresMap = pfafstetterNumber2FeaturesMap.get(pfafstetterNumber.toString());
        String criticSourceForHeigth = null;
        String criticSourceForDiameter = null;
        for (int i = 0; i < lastUpStreamPfafstetters.size(); i++) {
            PfafstetterNumber lastUpStreamPfafstetter = lastUpStreamPfafstetters.get(i);
            if (pfafstetterNumber.isDownStreamOf(lastUpStreamPfafstetter)) {
                /*
                     * if the other is directly upstream, check its max height and label 
                     * the critical section
                     */
                double lastUpstreamHeight = lastUpStreamMaxHeights.get(i);
                double lastUpstreamDiameter = lastUpStreamMaxDiameters.get(i);
                if (lastUpstreamHeight > maxUpstreamHeight) {
                    maxUpstreamHeight = lastUpstreamHeight;
                    criticSourceForHeigth = lastUpStreamCriticSourceForLength.get(i);
                }
                if (lastUpstreamDiameter > maxUpstreamDiameter) {
                    maxUpstreamDiameter = lastUpstreamDiameter;
                    criticSourceForDiameter = lastUpStreamCriticSourceForDiameter.get(i);
                }
            }
        }
        for (SimpleFeature feature : featuresMap.values()) {
            String linkid = feature.getAttribute(FIELD_LINKID).toString();
            double width = (Double) feature.getAttribute(WIDTH2);
            double height = (Double) feature.getAttribute(VEG_H);
            Object diameterObj = feature.getAttribute(VEG_DBH);
            double diameter;
            if (diameterObj instanceof Double) {
                diameter = (Double) diameterObj;
            } else {
                diameter = -1;
            }
            Object waterDepthObj = feature.getAttribute(FIELD_WATER_LEVEL2);
            double waterDepth;
            if (waterDepthObj instanceof Double) {
                waterDepth = (Double) waterDepthObj;
            } else {
                waterDepth = -1;
            }
            if (ext == null) {
                if (diameter < 0) {
                    ext = new FeatureExtender(inNetPoints.getSchema(), new String[] { FIELD_ISCRITIC_LOCAL_FOR_HEIGHT, FIELD_ISCRITIC_GLOBAL_FOR_HEIGHT, FIELD_CRITIC_SOURCE_FOR_HEIGHT }, new Class[] { Integer.class, Integer.class, String.class });
                } else {
                    ext = new FeatureExtender(inNetPoints.getSchema(), new String[] { FIELD_ISCRITIC_LOCAL_FOR_HEIGHT, FIELD_ISCRITIC_GLOBAL_FOR_HEIGHT, FIELD_CRITIC_SOURCE_FOR_HEIGHT, FIELD_ISCRITIC_LOCAL_FOR_DIAMETER, FIELD_ISCRITIC_GLOBAL_FOR_DIAMETER, FIELD_CRITIC_SOURCE_FOR_DIAMETER }, new Class[] { Integer.class, Integer.class, String.class, Integer.class, Integer.class, String.class });
                }
            }
            if (height > maxUpstreamHeight) {
                maxUpstreamHeight = height;
                criticSourceForHeigth = pfafstetterNumber + "-" + linkid;
            }
            /*
                 * label the critical sections
                 */
            // critical from local parameters veg_h > width
            int isCriticLocalForLogHeight = 0;
            int isCriticGlobalForLogHeight = 0;
            if (height / width > pRatioLogsLengthChannelWidthHillslope) {
                isCriticLocalForLogHeight = 1;
            }
            // critical on vegetation coming from upstream
            if (maxUpstreamHeight / width > pRatioLogsLengthChannelWidthChannel) {
                isCriticGlobalForLogHeight = 1;
                maxUpstreamHeight = -1;
            }
            // update the field with the origin of critical sections
            if (criticSourceForHeigth == null)
                criticSourceForHeigth = "";
            String tmpCriticSourceForHeight = criticSourceForHeigth;
            if (isCriticGlobalForLogHeight == 0) {
                tmpCriticSourceForHeight = "";
            }
            /*
                 * check on the ratio between the diameter of the logs and the channel depth will be
                 * done only if the dbh field in the input net points layer is available
                 */
            if (diameter > 0.0) {
                if (diameter > maxUpstreamDiameter) {
                    maxUpstreamDiameter = diameter;
                    criticSourceForDiameter = pfafstetterNumber + "-" + linkid;
                }
                int isCriticLocalForLogDiameter = 0;
                int isCriticGlobalForLogDiameter = 0;
                // critical from local parameters veg_d > waterdepth
                if (diameter / waterDepth > pRatioLogsDiameterWaterDepth) {
                    isCriticLocalForLogDiameter = 1;
                }
                // critical on vegetation coming from upstream
                if (maxUpstreamDiameter / waterDepth > pRatioLogsDiameterWaterDepth) {
                    isCriticGlobalForLogDiameter = 1;
                    maxUpstreamDiameter = -1;
                }
                if (criticSourceForDiameter == null)
                    criticSourceForDiameter = "";
                String tmpCriticSourceForDiameter = criticSourceForDiameter;
                if (isCriticGlobalForLogDiameter == 0) {
                    tmpCriticSourceForDiameter = "";
                }
                SimpleFeature newFeature = ext.extendFeature(feature, new Object[] { isCriticLocalForLogHeight, isCriticGlobalForLogHeight, tmpCriticSourceForHeight, isCriticLocalForLogDiameter, isCriticGlobalForLogDiameter, tmpCriticSourceForDiameter });
                outputFC.add(newFeature);
                lastUpStreamMaxDiameters.add(maxUpstreamDiameter);
                lastUpStreamCriticSourceForDiameter.add(criticSourceForDiameter);
            } else {
                // no other checks will be done for critical sections
                SimpleFeature newFeature = ext.extendFeature(feature, new Object[] { isCriticLocalForLogHeight, isCriticGlobalForLogHeight, tmpCriticSourceForHeight });
                outputFC.add(newFeature);
            }
        }
        // add the point to the list for the next step
        lastUpStreamPfafstetters.add(pfafstetterNumber);
        lastUpStreamMaxHeights.add(maxUpstreamHeight);
        lastUpStreamCriticSourceForLength.add(criticSourceForHeigth);
        pm.worked(1);
    }
    pm.done();
    outNetPoints = outputFC;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) SimpleFeature(org.opengis.feature.simple.SimpleFeature) PfafstetterNumber(org.hortonmachine.hmachine.modules.network.PfafstetterNumber) FeatureExtender(org.hortonmachine.gears.utils.features.FeatureExtender) DefaultFeatureCollection(org.geotools.feature.DefaultFeatureCollection) Execute(oms3.annotations.Execute)

Example 3 with Label

use of oms3.annotations.Label in project hortonmachine by TheHortonMachine.

the class HortonmachineModulesManager method init.

public void init() throws Exception {
    synchronized (modulesMap) {
        if (modulesMap.size() > 0) {
            return;
        }
    }
    LinkedHashMap<String, Class<?>> moduleNames2Classes = Modules.getInstance().moduleName2Class;
    // LinkedHashMap<String, List<ClassField>> moduleName2Fields =
    // Modules.getInstance().moduleName2Fields;
    LinkedHashMap<String, Class<?>> lestoModuleNames2Class = Lesto.getInstance().moduleName2Class;
    // LinkedHashMap<String, List<ClassField>> lestoModuleName2Fields =
    // Lesto.getInstance().moduleName2Fields;
    // also gather horton and gears
    HortonMachine.getInstance();
    Map<String, Class<?>> gearsModuleName2Class = JGrassGears.getInstance().moduleName2Class;
    for (Entry<String, Class<?>> entry : lestoModuleNames2Class.entrySet()) {
        String name = entry.getKey();
        if (name.startsWith("Oms")) {
            continue;
        }
        moduleNames2Classes.put(name, entry.getValue());
    }
    for (Entry<String, Class<?>> entry : gearsModuleName2Class.entrySet()) {
        String name = entry.getKey();
        if (name.startsWith("Oms")) {
            continue;
        }
        moduleNames2Classes.put(name, entry.getValue());
    }
    Collection<Class<?>> classesList = moduleNames2Classes.values();
    for (Class<?> moduleClass : classesList) {
        try {
            String simpleName = moduleClass.getSimpleName();
            UI uiHints = moduleClass.getAnnotation(UI.class);
            if (uiHints != null) {
                String uiHintStr = uiHints.value();
                if (uiHintStr.contains(HMConstants.HIDE_UI_HINT)) {
                    continue;
                }
            }
            Label category = moduleClass.getAnnotation(Label.class);
            String categoryStr = HMConstants.OTHER;
            if (category != null && categoryStr.trim().length() > 1) {
                categoryStr = category.value();
            }
            Description description = moduleClass.getAnnotation(Description.class);
            String descrStr = null;
            if (description != null) {
                descrStr = description.value();
            }
            Status status = moduleClass.getAnnotation(Status.class);
            ModuleDescription module = new ModuleDescription(moduleClass, categoryStr, descrStr, status);
            Object newInstance = null;
            try {
                newInstance = moduleClass.newInstance();
            } catch (Throwable e) {
                // ignore module
                continue;
            }
            try {
                // generate the html docs
                String className = module.getClassName();
            // FIXME
            // SpatialToolboxUtils.generateModuleDocumentation(className);
            } catch (Exception e) {
            // ignore doc if it breaks
            }
            ComponentAccess cA = new ComponentAccess(newInstance);
            Collection<Access> inputs = cA.inputs();
            for (Access access : inputs) {
                addInput(access, module);
            }
            Collection<Access> outputs = cA.outputs();
            for (Access access : outputs) {
                addOutput(access, module);
            }
            if (categoryStr.equals(HMConstants.GRIDGEOMETRYREADER) || categoryStr.equals(HMConstants.RASTERREADER) || categoryStr.equals(HMConstants.RASTERWRITER) || categoryStr.equals(HMConstants.FEATUREREADER) || categoryStr.equals(HMConstants.FEATUREWRITER) || categoryStr.equals(HMConstants.GENERICREADER) || categoryStr.equals(HMConstants.GENERICWRITER) || categoryStr.equals(HMConstants.HASHMAP_READER) || categoryStr.equals(HMConstants.HASHMAP_WRITER) || categoryStr.equals(HMConstants.LIST_READER) || categoryStr.equals(HMConstants.LIST_WRITER)) {
            // ignore for now
            } else {
                List<ModuleDescription> modulesList4Category = modulesMap.get(categoryStr);
                if (modulesList4Category == null) {
                    modulesList4Category = new ArrayList<ModuleDescription>();
                    modulesMap.put(categoryStr, modulesList4Category);
                }
                modulesList4Category.add(module);
            }
        } catch (NoClassDefFoundError e) {
            if (moduleClass != null)
                Logger.INSTANCE.insertError("", "ERROR", e.getCause());
        }
    }
    // sort
    Set<Entry<String, List<ModuleDescription>>> entrySet = modulesMap.entrySet();
    for (Entry<String, List<ModuleDescription>> entry : entrySet) {
        Collections.sort(entry.getValue(), new ModuleDescription.ModuleDescriptionNameComparator());
    }
}
Also used : Description(oms3.annotations.Description) Label(oms3.annotations.Label) Access(oms3.Access) ComponentAccess(oms3.ComponentAccess) Entry(java.util.Map.Entry) ComponentAccess(oms3.ComponentAccess) UI(oms3.annotations.UI) ArrayList(java.util.ArrayList) List(java.util.List) Status(oms3.annotations.Status)

Example 4 with Label

use of oms3.annotations.Label in project hortonmachine by TheHortonMachine.

the class Lesto method main.

public static void main(String[] args) throws IOException {
    Lesto hm = Lesto.getInstance();
    Set<Entry<String, Class<?>>> cls = hm.moduleName2Class.entrySet();
    for (Entry<String, Class<?>> cl : cls) {
        System.out.println(cl.getValue().getCanonicalName());
    }
    if (true)
        return;
    LinkedHashMap<String, List<ClassField>> moduleName2Fields = hm.moduleName2Fields;
    LinkedHashMap<String, Class<?>> moduleName2Class = hm.moduleName2Class;
    Set<Entry<String, List<ClassField>>> entrySet = moduleName2Fields.entrySet();
    for (Entry<String, List<ClassField>> entry : entrySet) {
        String moduleName = entry.getKey();
        StringBuilder sb = new StringBuilder();
        Class<?> moduleClass = moduleName2Class.get(moduleName);
        Description description = moduleClass.getAnnotation(Description.class);
        sb.append("public static final String " + moduleName.toUpperCase() + "_DESCRIPTION = \"" + description.value() + "\";\n");
        Documentation documentation = moduleClass.getAnnotation(Documentation.class);
        String doc;
        if (documentation == null) {
            doc = "";
        } else {
            doc = documentation.value();
        }
        sb.append("public static final String " + moduleName.toUpperCase() + "_DOCUMENTATION = \"" + doc + "\";\n");
        Keywords keywords = moduleClass.getAnnotation(Keywords.class);
        String k;
        if (keywords == null) {
            k = "";
        } else {
            k = keywords.value();
        }
        sb.append("public static final String " + moduleName.toUpperCase() + "_KEYWORDS = \"" + k + "\";\n");
        Label label = moduleClass.getAnnotation(Label.class);
        String lab;
        if (label == null) {
            lab = "";
        } else {
            lab = label.value();
        }
        sb.append("public static final String " + moduleName.toUpperCase() + "_LABEL = \"" + lab + "\";\n");
        Name name = moduleClass.getAnnotation(Name.class);
        String n;
        if (name == null) {
            n = "";
        } else {
            n = name.value();
        }
        sb.append("public static final String " + moduleName.toUpperCase() + "_NAME = \"" + n + "\";\n");
        Status status = moduleClass.getAnnotation(Status.class);
        // String st = "";
        // switch( status.value() ) {
        // case 5:
        // st = "EXPERIMENTAL";
        // break;
        // case 10:
        // st = "DRAFT";
        // break;
        // case 20:
        // st = "TESTED";
        // break;
        // case 30:
        // st = "VALIDATED";
        // break;
        // case 40:
        // st = "CERTIFIED";
        // break;
        // default:
        // st = "DRAFT";
        // break;
        // }
        sb.append("public static final int " + moduleName.toUpperCase() + "_STATUS = " + status.value() + ";\n");
        License license = moduleClass.getAnnotation(License.class);
        sb.append("public static final String " + moduleName.toUpperCase() + "_LICENSE = \"" + license.value() + "\";\n");
        Author author = moduleClass.getAnnotation(Author.class);
        String authorName = author.name();
        sb.append("public static final String " + moduleName.toUpperCase() + "_AUTHORNAMES = \"" + authorName + "\";\n");
        String authorContact = author.contact();
        sb.append("public static final String " + moduleName.toUpperCase() + "_AUTHORCONTACTS = \"" + authorContact + "\";\n");
        UI ui = moduleClass.getAnnotation(UI.class);
        if (ui != null) {
            sb.append("public static final String " + moduleName.toUpperCase() + "_UI = \"" + ui.value() + "\";\n");
        }
        List<ClassField> value = entry.getValue();
        for (ClassField classField : value) {
            String fieldName = classField.fieldName;
            if (fieldName.equals("pm")) {
                continue;
            }
            String fieldDescription = classField.fieldDescription;
            String str = "public static final String " + moduleName.toUpperCase() + "_" + fieldName + "_DESCRIPTION = \"" + fieldDescription + "\";\n";
            sb.append(str);
        }
        System.out.println(sb.toString());
        System.out.println();
    }
// for( String className : hm.allClasses ) {
// System.out.println(className);
// }
// for( String fieldName : hm.allFields ) {
// System.out.println(fieldName);
// }
}
Also used : Status(oms3.annotations.Status) Description(oms3.annotations.Description) Keywords(oms3.annotations.Keywords) Documentation(oms3.annotations.Documentation) Label(oms3.annotations.Label) License(oms3.annotations.License) Name(oms3.annotations.Name) Entry(java.util.Map.Entry) UI(oms3.annotations.UI) Author(oms3.annotations.Author) ArrayList(java.util.ArrayList) List(java.util.List) ClassField(org.hortonmachine.gears.libs.modules.ClassField)

Example 5 with Label

use of oms3.annotations.Label in project hortonmachine by TheHortonMachine.

the class Modules method main.

public static void main(String[] args) throws IOException {
    Modules mod = getInstance();
    Set<Entry<String, Class<?>>> cls = mod.moduleName2Class.entrySet();
    for (Entry<String, Class<?>> cl : cls) {
        System.out.println(cl.getValue().getCanonicalName());
    }
    if (true)
        return;
    LinkedHashMap<String, List<ClassField>> moduleName2Fields = mod.moduleName2Fields;
    LinkedHashMap<String, Class<?>> moduleName2Class = mod.moduleName2Class;
    Set<Entry<String, List<ClassField>>> entrySet = moduleName2Fields.entrySet();
    for (Entry<String, List<ClassField>> entry : entrySet) {
        String moduleName = entry.getKey();
        StringBuilder sb = new StringBuilder();
        Class<?> moduleClass = moduleName2Class.get(moduleName);
        Description description = moduleClass.getAnnotation(Description.class);
        sb.append("public static final String " + moduleName.toUpperCase() + "_DESCRIPTION = \"" + description.value() + "\";\n");
        Documentation documentation = moduleClass.getAnnotation(Documentation.class);
        String doc;
        if (documentation == null) {
            doc = "";
        } else {
            doc = documentation.value();
        }
        sb.append("public static final String " + moduleName.toUpperCase() + "_DOCUMENTATION = \"" + doc + "\";\n");
        Keywords keywords = moduleClass.getAnnotation(Keywords.class);
        String k;
        if (keywords == null) {
            k = "";
        } else {
            k = keywords.value();
        }
        sb.append("public static final String " + moduleName.toUpperCase() + "_KEYWORDS = \"" + k + "\";\n");
        Label label = moduleClass.getAnnotation(Label.class);
        String lab;
        if (label == null) {
            lab = "";
        } else {
            lab = label.value();
        }
        sb.append("public static final String " + moduleName.toUpperCase() + "_LABEL = \"" + lab + "\";\n");
        Name name = moduleClass.getAnnotation(Name.class);
        String n;
        if (name == null) {
            n = "";
        } else {
            n = name.value();
        }
        sb.append("public static final String " + moduleName.toUpperCase() + "_NAME = \"" + n + "\";\n");
        Status status = moduleClass.getAnnotation(Status.class);
        // String st = "";
        // switch( status.value() ) {
        // case 5:
        // st = "EXPERIMENTAL";
        // break;
        // case 10:
        // st = "DRAFT";
        // break;
        // case 20:
        // st = "TESTED";
        // break;
        // case 30:
        // st = "VALIDATED";
        // break;
        // case 40:
        // st = "CERTIFIED";
        // break;
        // default:
        // st = "DRAFT";
        // break;
        // }
        sb.append("public static final int " + moduleName.toUpperCase() + "_STATUS = " + status.value() + ";\n");
        License license = moduleClass.getAnnotation(License.class);
        sb.append("public static final String " + moduleName.toUpperCase() + "_LICENSE = \"" + license.value() + "\";\n");
        Author author = moduleClass.getAnnotation(Author.class);
        String authorName = author.name();
        sb.append("public static final String " + moduleName.toUpperCase() + "_AUTHORNAMES = \"" + authorName + "\";\n");
        String authorContact = author.contact();
        sb.append("public static final String " + moduleName.toUpperCase() + "_AUTHORCONTACTS = \"" + authorContact + "\";\n");
        UI ui = moduleClass.getAnnotation(UI.class);
        if (ui != null) {
            sb.append("public static final String " + moduleName.toUpperCase() + "_UI = \"" + ui.value() + "\";\n");
        }
        List<ClassField> value = entry.getValue();
        for (ClassField classField : value) {
            String fieldName = classField.fieldName;
            if (fieldName.equals("pm")) {
                continue;
            }
            String fieldDescription = classField.fieldDescription;
            String str = "public static final String " + moduleName.toUpperCase() + "_" + fieldName + "_DESCRIPTION = \"" + fieldDescription + "\";\n";
            sb.append(str);
        }
        System.out.println(sb.toString());
        System.out.println();
    }
// for( String className : jgr.allClasses ) {
// System.out.println(className);
// }
// for( String fieldName : jgr.allFields ) {
// System.out.println(fieldName);
// }
}
Also used : Status(oms3.annotations.Status) Description(oms3.annotations.Description) Keywords(oms3.annotations.Keywords) Documentation(oms3.annotations.Documentation) Label(oms3.annotations.Label) License(oms3.annotations.License) Name(oms3.annotations.Name) Entry(java.util.Map.Entry) UI(oms3.annotations.UI) Author(oms3.annotations.Author) ArrayList(java.util.ArrayList) List(java.util.List) ClassField(org.hortonmachine.gears.libs.modules.ClassField)

Aggregations

ArrayList (java.util.ArrayList)6 List (java.util.List)5 Entry (java.util.Map.Entry)5 Description (oms3.annotations.Description)5 Label (oms3.annotations.Label)5 Status (oms3.annotations.Status)5 UI (oms3.annotations.UI)5 Author (oms3.annotations.Author)4 Documentation (oms3.annotations.Documentation)4 Keywords (oms3.annotations.Keywords)4 License (oms3.annotations.License)4 Name (oms3.annotations.Name)4 ClassField (org.hortonmachine.gears.libs.modules.ClassField)4 HashMap (java.util.HashMap)1 TreeMap (java.util.TreeMap)1 Access (oms3.Access)1 ComponentAccess (oms3.ComponentAccess)1 Execute (oms3.annotations.Execute)1 DefaultFeatureCollection (org.geotools.feature.DefaultFeatureCollection)1 FeatureExtender (org.hortonmachine.gears.utils.features.FeatureExtender)1