genexuslabs / gxserver-client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GXServerClient - Java client for GeneXus Server services

About

A lightweight implementation of clients to Genexus Server services (eg: get hosted kbs, get revisions, etc.).

Group Id: com.genexus.gxserver
ArtifactId: gxserver-client

Usage examples

  1. Create a Client, eg: TeamWorkService2Client
  TeamWorkService2Client twClient = new TeamWorkService2Client(
          "https://samples.genexusserver.com/v17",
          "GeneXus Account\User",
          getPassword()
  );
  1. Get KBs and their basic info
  KBList kbs = twClient.getHostedKBs();
  for (KBInfo kb : kbs) {
    String kbName = kb.name;
    String kbDescription = kb.description;
    URL kbUrl = kb.url;
    String kbBase64Image = kb.base64Image;
    String kbTags = kb.tags;
    KBInfo.TeamDevMode kbTeamDevMode = kb.teamDevMode;
    String kbPublishUser = kb.publishUser;
    LocalDate kbPublishDate = kb.publishDate;

    // ...
  }
  1. Get KB versions and their info
  VersionList versions = twClient.getVersions(kb.name);
  for (VersionInfo version : versions) {
    int versionId = version.id;
    String versionName = version.name;
    UUID versionGuid = version.guid;
    UUID versionType = version.type;
    Boolean versionIsTrunk = version.isTrunk;
    int versionParentId = version.parentId;
    Boolean versionIsFrozen = version.isFrozen;
    int versionRemindsCount = version.remindsCount;

    // ...
  }
  1. Construct a Revisions Query and iterate results
// get yesterday's Date
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -1);
Date yesterday = cal.getTime();

// construct query (revisions since yesterday)
RevisionsQuery query = new RevisionsQuery(twClient, kb.name, version.name, yesterday);

// iterate revisions
for (RevisionInfo revision : query) {
  int revisionId = revision.id;
  UUID revisionGuid = revision.guid;
  String revisionAuthor = revision.author;
  Date revisionDate = revision.date;
  boolean revisionIsDisabled = revision.isDisabled;
  String revisionComment = revision.comment;

  // iterate actions in revision
  for (ActionInfo action : revision.getActions()) {
    UUID actionObjectGuid = action.objectGuid;
    String actionObjectKey = action.objectKey;
    String actionObjectType = action.objectType;
    String actionObjectName = action.objectName;
    String actionObjectDescription = action.objectDescription;
    ActionInfo.ActionType actionActionType = action.actionType;
    String actionUserName = action.userName;
    Date actionEditedTimestamp = action.editedTimestamp;

    // ...
  }

  // ...                
}

Note: See RevisionsQuery for other construction options.

  1. Get paginated version revisions and their actions
  int pageNumber = 1;
  String filterQuery = "";
  RevisionList revisions = twClient.getRevisions(kb.name, version.id, filterQuery, pageNumber);
  for (RevisionInfo revision : revisions) {
    int revisionId = revision.id;
    UUID revisionGuid = revision.guid;
    String revisionAuthor = revision.author;
    Date revisionDate = revision.date;
    boolean revisionIsDisabled = revision.isDisabled;
    String revisionComment = revision.comment;

    for (ActionInfo action : revision.getActions()) {
      UUID actionObjectGuid = action.objectGuid;
      String actionObjectKey = action.objectKey;
      String actionObjectType = action.objectType;
      String actionObjectName = action.objectName;
      String actionObjectDescription = action.objectDescription;
      ActionInfo.ActionType actionActionType = action.actionType;
      String actionUserName = action.userName;
      Date actionEditedTimestamp = action.editedTimestamp;

      // ...
    }

    // ...
  }

About

License:MIT License


Languages

Language:Java 100.0%