Package com.esri.gpt.catalog.discovery

Examples of com.esri.gpt.catalog.discovery.PropertyMeanings


   * @throws ParserConfigurationException if error parsing configuration
   */
  public PropertyMeanings loadPropertyMeanings()
    throws ParserConfigurationException, SAXException, IOException {
    Document dom = DomUtil.makeDomFromResourcePath("gpt/metadata/property-meanings.xml",false);   
    PropertyMeanings meanings = new PropertyMeanings();
    try {
      meanings.load(dom);
    } catch (XPathExpressionException e) {
      throw new IOException(
          "An XPath expression failed while loading property-meanings.xml: "+e.getMessage());
    }
    return meanings;
View Full Code Here


   * @throws IOException if an i/o exception occurs
   */
  public Schemas loadSchemas()
    throws ParserConfigurationException, SAXException, IOException {
    CfgContext cfgContext = new CfgContext(this);
    PropertyMeanings meanings = loadPropertyMeanings();
    Schemas schemas = new Schemas();
    schemas.setPropertyMeanings(meanings);
    loadSchemaFile(cfgContext,schemas,"gpt/metadata/schemas.xml");   
    return schemas;
  }
View Full Code Here

      }
     
      // determine the storeables
      Document document = new Document();   
      Storeables storeables = null;
      PropertyMeanings meanings = null;
      Indexables indexables = schema.getIndexables();
      if ((indexables != null) && (indexables.getIndexableContext() != null)) {
        meanings = indexables.getIndexableContext().getPropertyMeanings();
        storeables = (Storeables)indexables.getIndexableContext().getStoreables();
      }
      if (storeables == null) {
        useCollections = false;
        meanings= schema.getMeaning().getPropertyMeanings();
        storeables = (Storeables)schema.getMeaning().getStoreables();
      }
     
      // resolve the thumbnail URL         
      if (Val.chkStr(schema.getMeaning().getThumbnailUrl()).length() == 0) {
        String thumbBinary = Val.chkStr(schema.getMeaning().getThumbnailBinary());
        if ((thumbBinary != null) && (thumbBinary.length() > 0)) {
          String thumbUrl = "/thumbnail?uuid="+URLEncoder.encode(uuid,"UTF-8");
          //IStoreable storeable = schema.getMeaning().getStoreables().get(Meaning.MEANINGTYPE_THUMBNAIL_URL);
          IStoreable storeable = storeables.get(Meaning.MEANINGTYPE_THUMBNAIL_URL);
          if (storeable != null) {
            storeable.setValue(thumbUrl);
          } else {
            storeables.ensure(meanings,Meaning.MEANINGTYPE_THUMBNAIL_URL).setValue(thumbUrl);
          }
        }
      }
       
      // build the ACL property for the document
      acl = Val.chkStr(acl);
      MetadataAcl oAcl = new MetadataAcl(this.getRequestContext());
      String[] aclValues = oAcl.makeDocumentAcl(acl);
      AclProperty aclProp = new AclProperty(Storeables.FIELD_ACL);
      aclProp.setValues(aclValues);
     
      // build the document to store
      storeables.ensure(meanings,Storeables.FIELD_UUID).setValue(uuid);
      storeables.ensure(meanings,Storeables.FIELD_DATEMODIFIED).setValue(updateDate);
      storeables.add(aclProp);
     
      String fldName = null;
      Field fld = null;
     
      // document XML
      String xml = Val.chkStr(schema.getActiveDocumentXml());
      String testBrief = Val.chkStr(schema.getCswBriefXslt());
      if (alwaysStoreXmlInIndex || (testBrief.length() > 0)) {
        fldName = Storeables.FIELD_XML;
        LOGGER.log(Level.FINER, "Appending field: {0}", fldName);
        fld = new Field(fldName,xml,Field.Store.YES,Field.Index.NO,Field.TermVector.NO);
        document.add(fld);
      }
     
      // add additional indexable fields based upon the SQL database record
      boolean bReadDB = true;
      if (bReadDB) {
        CatalogConfiguration cfg = this.getRequestContext().getCatalogConfiguration();
        this.getRequestContext().getCatalogConfiguration().getResourceTableName();
        String sql = "SELECT SITEUUID, TITLE FROM "+cfg.getResourceTableName()+" WHERE DOCUUID=?";
        Connection con = this.returnConnection().getJdbcConnection();
        this.logExpression(sql);
        st = con.prepareStatement(sql);
        st.setString(1,uuid);
        ResultSet rs = st.executeQuery();
        if (rs.next()) {
         
          String dbVal = Val.chkStr(rs.getString("SITEUUID"));
          if (dbVal.length() > 0) {
            //storeables.ensure(meanings,Storeables.FIELD_SITEUUID).setValue(dbVal);
            fldName = Storeables.FIELD_SITEUUID;
            LOGGER.log(Level.FINER, "Appending field: {0} ={1}", new Object[]{fldName, dbVal});
            fld = new Field(fldName,dbVal,Field.Store.YES,Field.Index.NOT_ANALYZED,Field.TermVector.NO);
            document.add(fld);
          }

          dbVal = Val.chkStr(rs.getString("TITLE"));
          if (dbVal.length() > 0) {
            // if the title is found and is different than that in the database
            // it means that title from the database is typed by the user. In
            // that case make 'title.org' element based on the current title.
            IStoreable iTitle = storeables.get(Meaning.MEANINGTYPE_TITLE);
            if (iTitle!=null) {
              Object [] values = iTitle.getValues();
              if (values.length>0 && values[0] instanceof String) {
                String val = (String)values[0];
                if (!val.equals(dbVal)) {
                  storeables.ensure(meanings,Meaning.MEANINGTYPE_TITLE_ORG).setValue(val);
                }
              }
            }
            // ensure the title from the database
            storeables.ensure(meanings,Meaning.MEANINGTYPE_TITLE).setValue(dbVal);
          }
         
        }
        st.close();
        st = null;
       
        // determine collection membership
        if (useCollections && hasCollections) {
          ArrayList<String> alCol = new ArrayList<String>();
          stCol = con.prepareStatement(sqlCol);
          stCol.setString(1,uuid);
          ResultSet rsCol = stCol.executeQuery();
          while (rsCol.next()) {
            String sCUuid = rsCol.getString(1);
            for (String[] col: collections) {
              if (sCUuid.equals(col[0])) { 
                alCol.add(col[1]);
                break;
              }
            }
          }
          stCol.close();
          stCol = null;
          if (alCol.size() > 0) {
            fldName = "isPartOf";
            Storeable storeable = (Storeable)storeables.ensure(meanings,fldName);
            if (storeable == null) {
              // TODO: add a warning message to the log
            } else {
              indexables.getIndexableContext().addStorableValues(
                meanings.get(fldName),alCol.toArray(new String[0]));
            }
          }
        }
      }
View Full Code Here

   * Constructs with an associated request context.
   * @param requestContext the active request context
   */
  public StatsRequest(RequestContext requestContext) {
    CatalogConfiguration catCfg = requestContext.getCatalogConfiguration();
    PropertyMeanings meanings = catCfg.getConfiguredSchemas().getPropertyMeanings();
    this.requestContext = requestContext;
    this.storeables = new Storeables(meanings);
    if ((requestContext != null) && (requestContext.getServletRequest() != null) &&
        (requestContext.getServletRequest() instanceof HttpServletRequest)) {
      HttpServletRequest http = (HttpServletRequest)requestContext.getServletRequest();
View Full Code Here

TOP

Related Classes of com.esri.gpt.catalog.discovery.PropertyMeanings

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.