Examples of RegisterOntologyResult


Examples of org.mmisw.orrclient.gwt.client.rpc.RegisterOntologyResult

    ontCreator.createOntology(createVocabResult);
  }

 
  public RegisterOntologyResult registerOntology(CreateOntologyResult createOntologyResult, LoginResult loginResult) {
    RegisterOntologyResult registerOntologyResult = null;
   
    if ( createOntologyResult.getCreateOntologyInfo().getHostingType() != null ) {
      // use of this attribute indicates to use the new method
      registerOntologyResult = registerOntology_newMethod(createOntologyResult, loginResult);
    }
View Full Code Here

Examples of org.mmisw.orrclient.gwt.client.rpc.RegisterOntologyResult

  public RegisterOntologyResult registerOntology_newMethod(CreateOntologyResult createOntologyResult, LoginResult loginResult) {
    final HostingType hostingType = createOntologyResult.getCreateOntologyInfo().getHostingType();
   
    log.info("registerOntology: called. hostingType = " +hostingType);
    RegisterOntologyResult registerOntologyResult = new RegisterOntologyResult();
   
    switch ( hostingType ) {
      case FULLY_HOSTED:
        return registerOntologyFullyHosted(createOntologyResult, registerOntologyResult, loginResult);
      case RE_HOSTED:
        return registerOntologyReHosted(createOntologyResult, registerOntologyResult, loginResult);
      default: {
        String error = "Hosting type "+hostingType+ " NOT yet implemented.";
        registerOntologyResult.setError(error);
        log.info(error);
        return registerOntologyResult;
      }
    }
View Full Code Here

Examples of org.mmisw.orrclient.gwt.client.rpc.RegisterOntologyResult

    return registerOntologyResult;
  }

 
  public RegisterOntologyResult registerOntology_oldMethod(CreateOntologyResult createOntologyResult, LoginResult loginResult) {
    RegisterOntologyResult registerOntologyResult = new RegisterOntologyResult();
   
   
    String full_path = createOntologyResult.getFullPath();
   
    log.info("registerOntology: Reading in temporary file: " +full_path);
   
    File file = new File(full_path);
    if ( ! file.canRead() ) {
      String error = "Unexpected: cannot read: " +full_path;
      log.info(error);
      registerOntologyResult.setError(error);
      return registerOntologyResult;
    }
   
    // Get resulting model:
    String rdf;
    try {
//      rdf = Util2.readRdf(file);
      rdf = Util2.readRdfWithCheckingUtf8(file);
    }
    catch (Throwable e) {
      String error = "Unexpected: error while reading from: " +full_path+ " : " +e.getMessage();
      log.info(error);
      registerOntologyResult.setError(error);
      return registerOntologyResult;
    }
   
    // ok, we have our ontology:
   
   
    //////////////////////////////////////////////////////////////////////////
    // finally, do actual registration to MMI registry

    // Get final URI of resulting model
    // FIXME this uses the same original URI
    final String uri = createOntologyResult.getUri();
    assert uri != null;
    assert loginResult.getUserId() != null;
    assert loginResult.getSessionId() != null;
   
    log.info(": registering ...");

    CreateOntologyInfo createOntologyInfo = createOntologyResult.getCreateOntologyInfo();

    String ontologyId = createOntologyInfo.getPriorOntologyInfo().getOntologyId();
    String ontologyUserId = createOntologyInfo.getPriorOntologyInfo().getOntologyUserId();
   
    if ( ontologyId != null ) {
      log.info("Will create a new version for ontologyId = " +ontologyId+ ", userId=" +ontologyUserId);
    }
   
   
    Map<String, String> newValues = createOntologyInfo .getMetadataValues();
   

    try {
     
      String fileName = new URL(uri).getPath();
     
      //
      // make sure the fileName ends with ".owl" as the aquaportal back-end seems
      // to add that fixed extension in some operations (at least in the parse operation)
      //
      if ( ! fileName.toLowerCase().endsWith(".owl") ) {
        log.info("register: setting file extension to .owl per aquaportal requirement.");
        fileName += ".owl";
      }
     
     
      if ( ! createOntologyResult.isPreserveOriginalBaseNamespace() ) {
        // We are about to do the actual registration. But first, re-check that there is NO a preexisting
        // ontology that may conflict with this one.
        // NOTE: this check has been done already in the review operation; however, we repeat it here
        // in case there is a new registration done by other user in the meantime. Of course, we
        // are NOT completely solving the potential concurrency problem with this re-check; we are just
        // reducing the chances of that event.
        if ( ontologyId == null ) {
         
          final String namespaceRoot = newValues.get("namespaceRoot") != null
              ? newValues.get("namespaceRoot")
              :  defaultNamespaceRoot;
 
          final String orgAbbreviation = newValues.get(OmvMmi.origMaintainerCode.getURI());
          final String shortName = newValues.get(Omv.acronym.getURI());
 
          if ( ! Util2.checkNoPreexistingOntology(namespaceRoot, orgAbbreviation, shortName, registerOntologyResult) ) {
            return registerOntologyResult;
          }
 
        }
        else {
          // This is a submission of a *new version* of an existing ontology.
          // Nothing needs to be checked here.
          // NOTE: We don't need to repeat the _checkUriKeyCombinationForNewVersion step here
          // as any change in the contents of the metadata forces the user to explicitly
          // do the "review" operation, which already takes care of that check.
        }
      }
     
      // OK, now do the actual registration:
      OntologyUploader createOnt = new OntologyUploader(uri, fileName, rdf,
          loginResult,
          ontologyId, ontologyUserId,
          newValues
      );
      String res = createOnt.create();
     
      if ( res.startsWith("OK") ) {
        registerOntologyResult.setUri(uri);
        registerOntologyResult.setInfo(res);
       
        // issue #168 fix:
        // request that the ontology be loaded in the "ont" graph:
        OntServiceUtil.loadOntologyInGraph(uri, null);
      }
      else {
        registerOntologyResult.setError(res);
      }
    }
    catch (Exception ex) {
      ex.printStackTrace();
      registerOntologyResult.setError(ex.getClass().getName()+ ": " +ex.getMessage());
    }
   
    log.info("registerOntologyResult = " +registerOntologyResult);

   
View Full Code Here

Examples of org.mmisw.orrclient.gwt.client.rpc.RegisterOntologyResult

    createOntologyInfo.setDataCreationInfo(dataCreationInfo);
   
    // set info of original ontology:
    createOntologyInfo.setBaseOntologyInfo(tempOntologyInfo);
   
    RegisterOntologyResult registerOntologyResult = orrClient.registerOntologyDirectly(loginResult, null, createOntologyInfo, graphId);
    if ( registerOntologyResult.getError() != null ) {
      throw new Exception("Error registering ontology: " +registerOntologyResult.getError());
    }
   
    // OK!
    return registerOntologyResult;
  }
View Full Code Here

Examples of org.mmisw.orrclient.gwt.client.rpc.RegisterOntologyResult

    createOntologyInfo.setDataCreationInfo(dataCreationInfo);
   
    // set info of original ontology:
    createOntologyInfo.setBaseOntologyInfo(tempOntologyInfo);
   
    RegisterOntologyResult registerOntologyResult = orrClient.registerOntologyDirectly(loginResult, registeredOntologyInfo, createOntologyInfo, graphId);
    if ( registerOntologyResult.getError() != null ) {
      throw new Exception("Error registering ontology: " +registerOntologyResult.getError());
    }
   
    // OK!
    return registerOntologyResult;
View Full Code Here

Examples of org.mmisw.orrclient.gwt.client.rpc.RegisterOntologyResult

    ontCreator.createOntology(createVocabResult);
  }

 
  public RegisterOntologyResult registerOntology(CreateOntologyResult createOntologyResult, LoginResult loginResult) {
    RegisterOntologyResult registerOntologyResult = null;

        CreateOntologyInfo createOntologyInfo = createOntologyResult.getCreateOntologyInfo();
    if ( createOntologyInfo.getHostingType() != null ) {
      // use of this attribute indicates to use the new method
      registerOntologyResult = registerOntology_newMethod(createOntologyResult, loginResult);
    }
    else {
      registerOntologyResult = registerOntology_oldMethod(createOntologyResult, loginResult);
    }

        if (registerOntologyResult.getError() == null) {
            /////////////////////////////////////////////////////////////////////////
            // send email to notify successful registration
            // (this is very ad hoc -- will be more configurable in a next version)
            /////////////////////////////////////////////////////////////////////////

            // TODO update to reuse auxiliary methods introduced later

            final Set<String> recipients = new LinkedHashSet<String>();
            try {
                File f = new File(notifyEmailsFilename);
                FileInputStream is = new FileInputStream(f);
                for (Object line: IOUtils.readLines(is)) {
                    String email = String.valueOf(line).trim();
                    if (email.length() > 0 && !email.startsWith("#")) {
                        recipients.add(email);
                    }
                }
                IOUtils.closeQuietly(is);
            }
            catch (Exception e) {
                log.warn("could not read in: " + notifyEmailsFilename, e);
            }

            if (recipients.size() > 0) {
                final Map<String, String> data = new LinkedHashMap<String, String>();
                try {
                    String ontologyUri = registerOntologyResult.getUri();
                    String version = null;
                    String withUriParam = null;

                    if ( OntServiceUtil.isOntResolvableUri(ontologyUri) ) {
                        // prefer to show the unversioned URI
View Full Code Here

Examples of org.mmisw.orrclient.gwt.client.rpc.RegisterOntologyResult

  public RegisterOntologyResult registerOntology_newMethod(CreateOntologyResult createOntologyResult, LoginResult loginResult) {
    final HostingType hostingType = createOntologyResult.getCreateOntologyInfo().getHostingType();
   
    log.info("registerOntology: called. hostingType = " +hostingType);
    RegisterOntologyResult registerOntologyResult = new RegisterOntologyResult();
   
    switch ( hostingType ) {
      case FULLY_HOSTED:
        return registerOntologyFullyHosted(createOntologyResult, registerOntologyResult, loginResult);
      case RE_HOSTED:
        return registerOntologyReHosted(createOntologyResult, registerOntologyResult, loginResult);
      default: {
        String error = "Hosting type "+hostingType+ " NOT yet implemented.";
        registerOntologyResult.setError(error);
        log.info(error);
        return registerOntologyResult;
      }
    }
View Full Code Here

Examples of org.mmisw.orrclient.gwt.client.rpc.RegisterOntologyResult

    return registerOntologyResult;
  }

 
  public RegisterOntologyResult registerOntology_oldMethod(CreateOntologyResult createOntologyResult, LoginResult loginResult) {
    RegisterOntologyResult registerOntologyResult = new RegisterOntologyResult();
   
   
    String full_path = createOntologyResult.getFullPath();
   
    log.info("registerOntology: Reading in temporary file: " +full_path);
   
    File file = new File(full_path);
    if ( ! file.canRead() ) {
      String error = "Unexpected: cannot read: " +full_path;
      log.info(error);
      registerOntologyResult.setError(error);
      return registerOntologyResult;
    }
   
    // Get resulting model:
    String rdf;
    try {
//      rdf = Util2.readRdf(file);
      rdf = Util2.readRdfWithCheckingUtf8(file);
    }
    catch (Throwable e) {
      String error = "Unexpected: error while reading from: " +full_path+ " : " +e.getMessage();
      log.info(error);
      registerOntologyResult.setError(error);
      return registerOntologyResult;
    }
   
    // ok, we have our ontology:
   
   
    //////////////////////////////////////////////////////////////////////////
    // finally, do actual registration to MMI registry

    // Get final URI of resulting model
    // FIXME this uses the same original URI
    final String uri = createOntologyResult.getUri();
    assert uri != null;
    assert loginResult.getUserId() != null;
    assert loginResult.getSessionId() != null;
   
    log.info(": registering ...");

    CreateOntologyInfo createOntologyInfo = createOntologyResult.getCreateOntologyInfo();

    String ontologyId = createOntologyInfo.getPriorOntologyInfo().getOntologyId();
    String ontologyUserId = createOntologyInfo.getPriorOntologyInfo().getOntologyUserId();
   
    if ( ontologyId != null ) {
      log.info("Will create a new version for ontologyId = " +ontologyId+ ", userId=" +ontologyUserId);
    }
   
   
    Map<String, String> newValues = createOntologyInfo .getMetadataValues();
   

    try {
     
      String fileName = new URL(uri).getPath();
     
      //
      // make sure the fileName ends with ".owl" as the aquaportal back-end seems
      // to add that fixed extension in some operations (at least in the parse operation)
      //
      if ( ! fileName.toLowerCase().endsWith(".owl") ) {
        log.info("register: setting file extension to .owl per aquaportal requirement.");
        fileName += ".owl";
      }
     
     
      if ( ! createOntologyResult.isPreserveOriginalBaseNamespace() ) {
        // We are about to do the actual registration. But first, re-check that there is NO a preexisting
        // ontology that may conflict with this one.
        // NOTE: this check has been done already in the review operation; however, we repeat it here
        // in case there is a new registration done by other user in the meantime. Of course, we
        // are NOT completely solving the potential concurrency problem with this re-check; we are just
        // reducing the chances of that event.
        if ( ontologyId == null ) {
         
          final String namespaceRoot = newValues.get("namespaceRoot") != null
              ? newValues.get("namespaceRoot")
              :  defaultNamespaceRoot;
 
          final String orgAbbreviation = newValues.get(OmvMmi.origMaintainerCode.getURI());
          final String shortName = newValues.get(Omv.acronym.getURI());
 
          if ( ! Util2.checkNoPreexistingOntology(namespaceRoot, orgAbbreviation, shortName, registerOntologyResult) ) {
            return registerOntologyResult;
          }
 
        }
        else {
          // This is a submission of a *new version* of an existing ontology.
          // Nothing needs to be checked here.
          // NOTE: We don't need to repeat the _checkUriKeyCombinationForNewVersion step here
          // as any change in the contents of the metadata forces the user to explicitly
          // do the "review" operation, which already takes care of that check.
        }
      }
     
      // OK, now do the actual registration:
      OntologyUploader createOnt = new OntologyUploader(uri, fileName, rdf,
          loginResult,
          ontologyId, ontologyUserId,
          newValues
      );
      String res = createOnt.create();
     
      if ( res.startsWith("OK") ) {
        registerOntologyResult.setUri(uri);
        registerOntologyResult.setInfo(res);
       
        // issue #168 fix:
        // request that the ontology be loaded in the "ont" graph:
        OntServiceUtil.loadOntologyInGraph(uri, null);
      }
      else {
        registerOntologyResult.setError(res);
      }
    }
    catch (Exception ex) {
      ex.printStackTrace();
      registerOntologyResult.setError(ex.getClass().getName()+ ": " +ex.getMessage());
    }
   
    log.info("registerOntologyResult = " +registerOntologyResult);

   
View Full Code Here

Examples of org.mmisw.orrclient.gwt.client.rpc.RegisterOntologyResult

      RegisteredOntologyInfo registeredOntologyInfo,
      CreateOntologyInfo createOntologyInfo,
      String graphId
  ) {
   
    RegisterOntologyResult registerOntologyResult = new RegisterOntologyResult();
   
    BaseOntologyInfo baseOntologyInfo = createOntologyInfo.getBaseOntologyInfo();
    if ( ! (baseOntologyInfo instanceof TempOntologyInfo ) ) {
      String error = "Unexpected: baseOntologyInfo is not TempOntologyInfo. It is " +baseOntologyInfo.getClass().getName();
      log.info(error);
      registerOntologyResult.setError(error);
      return registerOntologyResult;
    }
   
    TempOntologyInfo tempOntologyInfo = (TempOntologyInfo) baseOntologyInfo;
   
    String full_path = tempOntologyInfo.getFullPath();
   
    log.info("registerOntologyDirectly: Reading in temporary file: " +full_path);
   
    // get the RDF contents:
    File file = new File(full_path);
    String rdf;
    try {
      rdf = Util2.readRdfWithCheckingUtf8(file);
    }
    catch (Throwable e) {
      String error = "Unexpected: error while reading from: " +full_path+ " : " +e.getMessage();
      log.info(error);
      registerOntologyResult.setError(error);
      return registerOntologyResult;
    }
   
    // ok, we have our ontology:
   
   
    //////////////////////////////////////////////////////////////////////////
    // finally, do actual registration to MMI registry

    // Get final URI of resulting model
    final String uri = createOntologyInfo.getUri();
    assert uri != null;
    assert loginResult.getUserId() != null;
    assert loginResult.getSessionId() != null;
   
    log.info(": registering URI: " +uri+ " ...");

    String ontologyId = createOntologyInfo.getPriorOntologyInfo().getOntologyId();
    String ontologyUserId = createOntologyInfo.getPriorOntologyInfo().getOntologyUserId();
   
    if ( ontologyId != null ) {
      log.info("Will create a new version for ontologyId = " +ontologyId+ ", userId=" +ontologyUserId);
    }
   
   
    Map<String, String> newValues = createOntologyInfo .getMetadataValues();
   

    try {
      // this is to get the filename for the registration
      String fileName = AquaUtil.getAquaportalFilename(uri);
     
      // OK, now do the actual registration:
      OntologyUploader createOnt = new OntologyUploader(uri, fileName, rdf,
          loginResult,
          ontologyId, ontologyUserId,
          newValues
      );
      String res = createOnt.create();
     
      if ( res.startsWith("OK") ) {
        registerOntologyResult.setUri(uri);
        registerOntologyResult.setInfo(res);
       
        // request that the ontology be loaded in the desired graph:
        OntServiceUtil.loadOntologyInGraph(uri, graphId);
      }
      else {
        registerOntologyResult.setError(res);
      }
    }
    catch (Exception ex) {
      ex.printStackTrace();
      registerOntologyResult.setError(ex.getClass().getName()+ ": " +ex.getMessage());
    }
   
    log.info("registerOntologyResult = " +registerOntologyResult);

    return registerOntologyResult;
View Full Code Here

Examples of org.mmisw.orrclient.gwt.client.rpc.RegisterOntologyResult

    assertNull("No error in createOntologyResult", createOntologyResult.getError());
    log.debug("createOntologyResult = " +createOntologyResult);
   
   
    log.info("=============== registerOntology =================");
    RegisterOntologyResult registerOntologyResult = orrClient.registerOntology(createOntologyResult, loginResult);
    assertNull("No error in registerOntology", registerOntologyResult.getError());
    log.debug("createOntologyResult = " +createOntologyResult.getUri());
   
    log.info("=============== getOntologyInfo =================");
    RegisteredOntologyInfo registeredOntologyInfo = orrClient.getOntologyInfo(namespace);
    assertNull("No error in registeredOntologyInfo", registeredOntologyInfo.getError());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.