Changeset 2376


Ignore:
Timestamp:
11/29/12 14:07:14 (12 years ago)
Author:
herste
Message:

some more commenting

Location:
vlo/trunk/vlo_webapp/src/main/java/eu/clarin/cmdi/vlo
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • vlo/trunk/vlo_webapp/src/main/java/eu/clarin/cmdi/vlo/FacetConstants.java

    r1936 r2376  
    11package eu.clarin.cmdi.vlo;
    22
     3/**
     4 * A bunch of important constants.
     5 * Constants for each facet, resource types and some urls.
     6 */
    37public class FacetConstants {
    48
  • vlo/trunk/vlo_webapp/src/main/java/eu/clarin/cmdi/vlo/importer/CMDIData.java

    r2373 r2376  
    1212/**
    1313 * Represents a document of cmdi data.
     14 * Quite a central class to the metadata importer process.
    1415 */
    1516
     
    2021    private static final String SEARCH_SERVICE_TYPE = "SearchService";
    2122
     23    /**
     24     * The unique identifier of the cmdi file.
     25     */
    2226    private String id;
     27    /**
     28     * The associated solr document (not send to the solr server yet)
     29     */
     30    private SolrInputDocument doc;
     31
     32    // Lists for different types of resources.
    2333    private List<Resource> metaDataResources = new ArrayList<Resource>();
    24     private SolrInputDocument doc;
    2534    private List<Resource> dataResources = new ArrayList<Resource>();
    2635    private List<Resource> searchResources = new ArrayList<Resource>();
     
    3039    }
    3140
     41    /**
     42     * Sets a field in the doc to a certain value. Well, at least calls another (private) method that actually does this.
     43     * @param name
     44     * @param value
     45     * @param caseInsensitive
     46     */
    3247    public void addDocField(String name, String value, boolean caseInsensitive) {
    3348        if (FacetConstants.FIELD_ID.equals(name)) {
     
    3853    }
    3954
     55    /**
     56     * Sets a field in the doc to a certain value.
     57     * Before adding checks for duplicates.
     58     * @param name
     59     * @param value
     60     * @param caseInsensitive
     61     */
    4062    private void handleDocField(String name, String value, boolean caseInsensitive) {
    4163        if (doc == null) {
     
    6183    }
    6284
    63     //TODO CLARIN-type search resources (CQL endpoints) are not dealth with yet.
    64     //You can use this method to get the list and add it to the solr somehow :)
     85    /**
     86     * //TODO CLARIN-type search resources (CQL endpoints) are not dealth with yet.
     87     * you can use this method to get the list of SearchResources (== cql endpoints) and add it to the solr somehow :)
     88     */
    6589    public List<Resource> getSearchResources() {
    6690        return searchResources;
    6791    }
    6892
     93    /**
     94     * Processes a resource by adding it to the internal lists.
     95     * Supports metadata, data, and search service type of resources.
     96     * Emits a warning if another type of resource is encountered (not allowed according to the cmdi spec, but we try to be a tad robust).
     97     * @param resource
     98     * @param type
     99     * @param mimeType
     100     */
    69101    public void addResource(String resource, String type, String mimeType) {
    70102        if (METADATA_TYPE.equals(type)) {
  • vlo/trunk/vlo_webapp/src/main/java/eu/clarin/cmdi/vlo/importer/FacetConfiguration.java

    r1230 r2376  
    44import java.util.Collections;
    55import java.util.List;
     6
     7/**
     8 * Once created contains the information about the facets and such.
     9 * Just a container for some information, doesn't do processing.
     10 */
    611
    712public class FacetConfiguration {
     
    4247        return name;
    4348    }
    44    
     49
    4550    @Override
    4651    public String toString() {
     
    5156        return allowMultipleValues;
    5257    }
    53    
     58
    5459    public void setAllowMultipleValues(boolean allowMultipleValues) {
    5560        this.allowMultipleValues = allowMultipleValues;
  • vlo/trunk/vlo_webapp/src/main/java/eu/clarin/cmdi/vlo/importer/FacetMapping.java

    r1230 r2376  
    33import java.util.ArrayList;
    44import java.util.List;
     5
     6/**
     7 * A list of facets. One FacetConfiguration for each facet.
     8 */
    59
    610public class FacetMapping {
  • vlo/trunk/vlo_webapp/src/main/java/eu/clarin/cmdi/vlo/importer/FacetMappingFactory.java

    r1414 r2376  
    11package eu.clarin.cmdi.vlo.importer;
     2
     3import com.ximpleware.AutoPilot;
     4import com.ximpleware.NavException;
     5import com.ximpleware.VTDGen;
     6import com.ximpleware.VTDNav;
     7import eu.clarin.cmdi.vlo.FacetConstants;
     8import eu.clarin.cmdi.vlo.importer.FacetConceptMapping.FacetConcept;
     9import org.slf4j.Logger;
     10import org.slf4j.LoggerFactory;
    211
    312import java.io.File;
     
    514import java.io.IOException;
    615import java.text.DateFormat;
    7 import java.util.ArrayList;
    8 import java.util.Date;
    9 import java.util.Deque;
    10 import java.util.HashMap;
    11 import java.util.LinkedList;
    12 import java.util.List;
    13 import java.util.Map;
    14 import java.util.Set;
    15 
    16 import org.slf4j.Logger;
    17 import org.slf4j.LoggerFactory;
    18 
    19 import com.ximpleware.AutoPilot;
    20 import com.ximpleware.NavException;
    21 import com.ximpleware.VTDGen;
    22 import com.ximpleware.VTDNav;
    23 
    24 import eu.clarin.cmdi.vlo.FacetConstants;
    25 import eu.clarin.cmdi.vlo.importer.FacetConceptMapping.FacetConcept;
     16import java.util.*;
     17
     18/**
     19 * Creates facet-mappings (xpaths) from a configuration.
     20 * As they say "this is where the magic happens".
     21 * Also does some cashing.
     22 */
    2623
    2724public class FacetMappingFactory {
     
    3128    private Map<String, FacetMapping> mapping = new HashMap<String, FacetMapping>();
    3229
     30    /**
     31     * Our one instance of the FMF.
     32     */
    3333    private final static FacetMappingFactory INSTANCE = new FacetMappingFactory();
    3434
     
    4040    }
    4141
     42    /**
     43     * If cashed gives that result, otherwise makes a new one (in the createMapping method below)..
     44     * @param xsd
     45     * @return
     46     */
    4247    private FacetMapping getOrCreateMapping(String xsd) {
    4348        FacetMapping result = mapping.get(xsd);
     
    4954    }
    5055
     56    /**
     57     * Asks conceptLinkPathMapping to create the actual xpaths.
     58     * Does a bunch of bookkeeping in order to get the FacetMapping.
     59     * @param xsd
     60     * @return
     61     */
    5162    private FacetMapping createMapping(String xsd) {
    5263        FacetMapping result = new FacetMapping();
     64        // Gets the configuration. VLOMarchaller only reads in the facetconceptmapping.xml file and returns the result (though the reading in is implicit).
    5365        FacetConceptMapping conceptMapping = VLOMarshaller.getFacetConceptMapping();
    5466        try {
     67            //The magic
    5568            Map<String, List<String>> conceptLinkPathMapping = createConceptLinkPathMapping(xsd);
     69            // Below we put the stuff we found into the configuration class.
    5670            for (FacetConcept facetConcept : conceptMapping.getFacetConcepts()) {
    5771                FacetConfiguration config = new FacetConfiguration();
     
    8498    /**
    8599     * The id facet is special case and patterns must be added first.
    86      * The standard pattern to get the id out of the header is the most reliable and it should fall back on concept matching of nothing matches.
    87      * (Note this is the exact opposite of other facets where the concept match is probably better then the 'hardcoded' pattern). 
     100     * The standard pattern to get the id out of the header is the most reliable and it should fall back on concept matching if nothing matches.
     101     * (Note this is the exact opposite of other facets where the concept match is probably better then the 'hardcoded' pattern).
    88102     */
    89103    private void handleId(List<String> xpaths, FacetConcept facetConcept) {
     
    93107    }
    94108
     109    /**
     110     * "this is where the magic happens".
     111     * Finds paths in the xsd to all concepts (isocat data catagories).
     112     * @param xsd
     113     * @return
     114     * @throws NavException
     115     */
    95116    private Map<String, List<String>> createConceptLinkPathMapping(String xsd) throws NavException {
    96117        Map<String, List<String>> result = new HashMap<String, List<String>>();
     
    142163    }
    143164
     165    /**
     166     * Given an xml-token path thingy create an xpath.
     167     * @param elementPath
     168     * @return
     169     */
    144170    private String createXpath(Deque<Token> elementPath) {
    145171        StringBuilder xpath = new StringBuilder("/");
     
    150176    }
    151177
     178    /**
     179     * does some updating after a step. To keep the path proper and path-y.
     180     * @param vn
     181     * @param elementPath
     182     * @param elementName
     183     */
    152184    private void updateElementPath(VTDNav vn, Deque<Token> elementPath, String elementName) {
    153185        int previousDepth = elementPath.isEmpty() ? -1 : elementPath.peekLast().depth;
Note: See TracChangeset for help on using the changeset viewer.