Examples of SimpleCommandLineParser


Examples of sample.util.SimpleCommandLineParser

    printResults(resultEntry);
  }

  private DocumentEntry createEntryFromArgs(String[] args) throws IOException {
    SimpleCommandLineParser parser = new SimpleCommandLineParser(args);

    DocumentEntry entry = new DocumentEntry();

    System.out.println("You want to create a new document...");

    String srcLang = parser.getValue("srclang");
    System.out.println("... with source language " + srcLang);
    entry.setSourceLanguage(new SourceLanguage(srcLang));

    String targetLang = parser.getValue("targetlang");
    System.out.println("... with target language " + targetLang);
    entry.setTargetLanguage(new TargetLanguage(targetLang));

    String title = parser.getValue("title");
    System.out.println("... with title " + title);
    entry.setTitle(new PlainTextConstruct(title));

    if (parser.containsKey("weburl")) {
      String url = parser.getValue("weburl");
      System.out.println("... with html contents from " + url);
      DocumentSource docSource = new DocumentSource(DocumentSource.Type.HTML,
          url);
      entry.setDocumentSource(docSource);
    } else if (parser.containsKey("wikipediaurl")) {
      String url = parser.getValue("wikipediaurl");
      System.out.println("... with mediawiki contents from " + url);
      DocumentSource docSource = new DocumentSource(DocumentSource.Type.WIKI,
          url);
      entry.setDocumentSource(docSource);
    } else if (parser.containsKey("knolurl")) {
      String url = parser.getValue("knolurl");
      System.out.println("... with knol contents from " + url);
      DocumentSource docSource = new DocumentSource(DocumentSource.Type.KNOL,
          url);
      entry.setDocumentSource(docSource);
    } else if (parser.containsKey("file")) {
      String filename = parser.getValue("file");
      System.out.println("... with contents from file at " + filename);
      File file = new File(filename);
      String mimeType = MediaType.fromFileName(filename).getMimeType();

      MediaFileSource fileSource = new MediaFileSource(file, mimeType);
      MediaContent content = new MediaContent();
      content.setMediaSource(fileSource);
      content.setMimeType(new ContentType(mimeType));

      entry.setContent(content);
    }

    if (parser.containsKey("tmids")) {
      String tmIds = parser.getValue("tmids");
      System.out.println("...by adding translation memories with ids: "
          + tmIds);
      TmsElement tm = new TmsElement();
      for (String id : tmIds.split(",")) {
        String tmHref = FeedUris.getTranslationMemoryFeedUrl(id).toString();

        Link tmLink = new Link();
        tmLink.setHref(tmHref);

        tm.addLink(tmLink);
      }
      entry.setTranslationMemory(tm);
    }

    if (parser.containsKey("glids")) {
      String glIds = parser.getValue("glids");
      System.out.println("...by adding glossaries with ids: "
          + glIds);
      GlossariesElement gl = new GlossariesElement();
      for (String id : glIds.split(",")) {
        String glHref = FeedUris.getGlossaryFeedUrl(id).toString();
View Full Code Here

Examples of sample.util.SimpleCommandLineParser

  private DeleteDocumentCommand() {
  }

  public void execute(GttService service, String[] args)
      throws IOException, ServiceException {
    SimpleCommandLineParser parser = new SimpleCommandLineParser(args);

    String docId = parser.getValue("id");
    boolean deletePermanently = parser.containsKey("perm");

    URL feedUrl;
    if (deletePermanently) {
      feedUrl = FeedUris.getDocumentPermDeleteUrl(docId);
    } else {
View Full Code Here

Examples of sample.util.SimpleCommandLineParser

    this.feedName = feedName;
  }

  public void execute(GttService service, String[] args)
      throws IOException, ServiceException {
    SimpleCommandLineParser parser = new SimpleCommandLineParser(args);

    String entryId = parser.getValue("id");

    if (parser.containsKey("list")) {
      URL feedUrl = FeedUris.getAclFeedUrl(feedName, entryId);

      System.out.println("Listing all accessors for " + feedName
          + " with id" + entryId + "  ...");
      // Get the list of accessors for this entry
      AclFeed aclFeed = service.getFeed(feedUrl, AclFeed.class);
      printAclInfo(aclFeed);

    } else if (parser.containsKey("changetype")) {
      String changeType = parser.getValue("changetype");
      String emailId = parser.getValue("email");

      if ("add".equals(changeType)) {
        AclScope scope = new AclScope(AclScope.Type.USER, emailId);
        AclRole role = new AclRole(parser.getValue("role"));

        // Add a new accessor for this entry
        AclEntry entry = new AclEntry();
        entry.setRole(role);
        entry.setScope(scope);

        System.out.println("Adding user " + emailId + " as " + role.getValue()
            + " to " + feedName + " with id " + entryId + " ...");
        URL feedUrl = FeedUris.getAclFeedUrl(feedName, entryId);
        service.insert(feedUrl, entry);
        System.out.println("...done");

      } else if ("change".equals(changeType)) {
        AclScope scope = new AclScope(AclScope.Type.USER, emailId);
        AclRole role = new AclRole(parser.getValue("role"));

        // Change the role of an accessor for this entry
        AclEntry entry = new AclEntry();
        entry.setRole(role);
        entry.setScope(scope);
View Full Code Here

Examples of sample.util.SimpleCommandLineParser

    printResults(resultEntry);
  }

  private TranslationMemoryEntry createEntryFromArgs(String[] args)
      throws IOException {
    SimpleCommandLineParser parser = new SimpleCommandLineParser(args);

    System.out.println("You asked to add translation memory...");

    TranslationMemoryEntry entry = new TranslationMemoryEntry();

    String title = parser.getValue("title");
    System.out.println("...with title " + title);
    entry.setTitle(new PlainTextConstruct(title));

    if (parser.containsKey("file")) {
      String filename = parser.getValue("file");
      System.out.println("...with contents from " + filename);
      File file = new File(filename);
      String mimeType = "text/xml";

      MediaFileSource fileSource = new MediaFileSource(file, mimeType);
      MediaContent content = new MediaContent();
      content.setMediaSource(fileSource);
      content.setMimeType(new ContentType(mimeType));

      entry.setContent(content);
    }

    if (parser.containsKey("private")) {
      System.out.println("...with private access");
      entry.setScope(new ScopeEntry(ScopeEntry.Value.PRIVATE));
    } else {
      System.out.println("...with public access");
      entry.setScope(new ScopeEntry(ScopeEntry.Value.PUBLIC));
View Full Code Here

Examples of sample.util.SimpleCommandLineParser

  private DeleteGlossaryCommand() {
  }

  public void execute(GttService service, String[] args)
      throws IOException, ServiceException {
    SimpleCommandLineParser parser = new SimpleCommandLineParser(args);

    String id = parser.getValue("id");
    URL feedUrl = FeedUris.getGlossaryFeedUrl(id);

    System.out.print("Deleting glossary with id: " + id + " ....");
    System.out.flush();
View Full Code Here

Examples of sample.util.SimpleCommandLineParser

    printResults(resultFeed);
  }

  private TranslationMemoryQuery createQueryFromArgs(String[] args)
      throws IOException {
    SimpleCommandLineParser parser = new SimpleCommandLineParser(args);

    URL feedUrl = FeedUris.getTranslationMemoriesFeedUrl();
    TranslationMemoryQuery query = new TranslationMemoryQuery(feedUrl);

    if (parser.containsKey("onlyprivate")) {
      System.out.println("You asked to list all private translation "
          + "memories...");
      query.setScope(ScopeEntry.Value.PRIVATE.toString());
    } else if (parser.containsKey("onlypublic")) {
      System.out.println("You asked to list all public translation "
          + "memories...");
      query.setScope(ScopeEntry.Value.PUBLIC.toString());
    } else {
      System.out.println("You asked to list all translation "
View Full Code Here

Examples of sample.util.SimpleCommandLineParser

  private DeleteTranslationMemoryCommand() {
  }

  public void execute(GttService service, String[] args)
      throws IOException, ServiceException {
    SimpleCommandLineParser parser = new SimpleCommandLineParser(args);

    String id = parser.getValue("id");
    URL feedUrl = FeedUris.getTranslationMemoryFeedUrl(id);

    System.out.print("Deleting translation memory with id: " + id + " ....");
    System.out.flush();
View Full Code Here

Examples of sample.util.SimpleCommandLineParser

    printResults(resultEntry);
  }

  private GlossaryEntry createEntryFromArgs(String[] args)
      throws IOException {
    SimpleCommandLineParser parser = new SimpleCommandLineParser(args);

    System.out.println("You asked to add a glossary...");

    GlossaryEntry entry = new GlossaryEntry();

    String title = parser.getValue("title");
    System.out.println("...with title " + title);
    entry.setTitle(new PlainTextConstruct(title));

    String filename = parser.getValue("file");
    System.out.println("...with contents from " + filename);
    File file = new File(filename);
    String mimeType = "text/csv";
    MediaFileSource fileSource = new MediaFileSource(file, mimeType);
    MediaContent content = new MediaContent();
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.