Package com.google.gdata.data.gtt

Examples of com.google.gdata.data.gtt.TranslationMemoryEntry


    SimpleCommandLineParser parser = new SimpleCommandLineParser(args);

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

    TranslationMemoryEntry requestEntry = service.getEntry(feedUrl,
        TranslationMemoryEntry.class);

    System.out.println("You want to update translation memory with id:"
        + id + " ...");

    if (parser.containsKey("title")) {
      String title = parser.getValue("title");
      System.out.println("...by changing title to " + title);
      requestEntry.setTitle(new PlainTextConstruct(title));
    }

    if (parser.containsKey("file")) {
      String filename = parser.getValue("file");
      System.out.println("...by appending contents from file " + 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));

      requestEntry.setContent(content);
    }

    System.out.print("Updating translation memory....");
    System.out.flush();

    TranslationMemoryEntry resultEntry = null;
    if (requestEntry.getContent() == null) {
      resultEntry = service.update(feedUrl, requestEntry);
    } else {
      resultEntry = service.updateMedia(feedUrl, requestEntry);
    }
View Full Code Here


  private AddTranslationMemoryCommand() {
  }

  public void execute(GttService service, String[] args)
      throws IOException, ServiceException {
    TranslationMemoryEntry requestEntry = createEntryFromArgs(args);

    System.out.print("Adding tm....");
    System.out.flush();

    URL feedUrl = FeedUris.getTranslationMemoriesFeedUrl();
    TranslationMemoryEntry resultEntry = service.insert(feedUrl, requestEntry);

    printResults(resultEntry);
  }
View Full Code Here

      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));
    }

    return entry;
  }
View Full Code Here

TOP

Related Classes of com.google.gdata.data.gtt.TranslationMemoryEntry

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.