Package com.getperka.flatpack.client.dto

Examples of com.getperka.flatpack.client.dto.ApiDescription


        new ObjectModelAdaptor() {
          @Override
          public Object getProperty(Interpreter interp, ST self, Object o,
              Object property, String propertyName)
              throws STNoSuchPropertyException {
            ApiDescription apiDescription = (ApiDescription) o;
            if ("endpoints".equals(propertyName)) {
              Set<EndpointDescription> uniqueEndpoints =
                  new HashSet<EndpointDescription>(apiDescription.getEndpoints());
              List<EndpointDescription> sortedEndpoints = new ArrayList<EndpointDescription>(
                  uniqueEndpoints);
              Collections.sort(sortedEndpoints, new Comparator<EndpointDescription>() {
                @Override
                public int compare(EndpointDescription e1, EndpointDescription e2) {
                  return e1.getPath().compareTo(e2.getPath());
                }
              });
              Iterator<EndpointDescription> iter = sortedEndpoints.iterator();
              while (iter.hasNext()) {
                EndpointDescription ed = iter.next();
                if (ed.getPath() != null && ed.getPath().contains("{path:.*}")) {
                  iter.remove();
                }
              }
              return sortedEndpoints;
            }
            else if ("flatpackEndpoints".equals(propertyName)) {
              List<EndpointDescription> sortedEndpoints = new ArrayList<EndpointDescription>(
                  apiDescription.getEndpoints());
              Collections.sort(sortedEndpoints, new Comparator<EndpointDescription>() {
                @Override
                public int compare(EndpointDescription e1, EndpointDescription e2) {
                  return e1.getPath().compareTo(e2.getPath());
                }
View Full Code Here


  @FlatPackResponse(ApiDescription.class)
  public ApiDescription describeGet() throws IOException {
    FlatPack flatpack = providers.getContextResolver(FlatPack.class, MediaType.WILDCARD_TYPE)
        .getContext(FlatPack.class);
    ApiDescriber api = new ApiDescriber(flatpack, Arrays.asList(DemoResource.class.getMethods()));
    ApiDescription description = api.describe();
    description.setApiName("Demo");
    return description;
  }
View Full Code Here

        new ObjectModelAdaptor() {
          @Override
          public Object getProperty(Interpreter interp, ST self, Object o,
              Object property, String propertyName)
              throws STNoSuchPropertyException {
            ApiDescription apiDescription = (ApiDescription) o;
            if ("endpoints".equals(propertyName)) {
              List<EndpointDescription> sortedEndpoints = new ArrayList<EndpointDescription>(
                  apiDescription.getEndpoints());
              Collections.sort(sortedEndpoints, new Comparator<EndpointDescription>() {
                @Override
                public int compare(EndpointDescription e1, EndpointDescription e2) {
                  return e1.getPath().compareTo(e2.getPath());
                }
              });
              return sortedEndpoints;
            }
            else if ("importNames".equals(propertyName)) {
              Set<String> imports = new HashSet<String>();
              for (EndpointDescription e : apiDescription.getEndpoints()) {
                if (e.getEntity() != null) {
                  String type = objcTypeForType(e.getEntity());
                  if (isRequiredImport(type)) {
                    imports.add(type);
                  }
View Full Code Here

        set.addAll(chain);
        entity = entity.getSupertype();
      }
    }

    ApiDescription description = new ApiDescription();
    description.setApiName(apiName);

    List<EntityDescription> entities = new ArrayList<EntityDescription>();
    description.setEntities(entities);

    // Extract API endpoints
    Set<EndpointDescription> endpoints = new LinkedHashSet<EndpointDescription>();

    for (Method method : apiMethods) {
      EndpointDescription desc = describeEndpoint(method);
      if (desc != null) {
        endpoints.add(desc);
      }
    }
    description.setEndpoints(new ArrayList<EndpointDescription>(endpoints));

    // Extract all entities
    Set<Class<?>> seen = setForLookup();
    do {
      Set<Class<? extends HasUuid>> toProcess = entitiesToExtract;
View Full Code Here

  public void test() throws Exception {
    Method method = ApiDescriberTest.class.getDeclaredMethod("sampleMethod");

    FlatPack flatpack = FlatPack.create(new Configuration()
        .addTypeSource(new SearchTypeSource("com.getperka.flatpack")));
    ApiDescription description = new ApiDescriber(flatpack, Collections.singletonList(method))
        .describe();

    EntityDescription toCheck = null;
    for (EntityDescription desc : description.getEntities()) {
      if ("apiDescription".equals(desc.getTypeName())) {
        toCheck = desc;
        break;
      }
    }
View Full Code Here

        new ObjectModelAdaptor() {
          @Override
          public Object getProperty(Interpreter interp, ST self, Object o,
              Object property, String propertyName)
              throws STNoSuchPropertyException {
            ApiDescription apiDescription = (ApiDescription) o;
            if ("endpoints".equals(propertyName)) {
              Set<EndpointDescription> uniqueEndpoints =
                  new HashSet<EndpointDescription>(apiDescription.getEndpoints());
              List<EndpointDescription> sortedEndpoints = new ArrayList<EndpointDescription>(
                  uniqueEndpoints);
              Collections.sort(sortedEndpoints, new Comparator<EndpointDescription>() {
                @Override
                public int compare(EndpointDescription e1, EndpointDescription e2) {
View Full Code Here

        .getUnpacker();

    logger.info("Retrieving {}", source);
    Reader reader = new InputStreamReader(source.toURL().openStream(), Charset.forName("UTF8"));

    ApiDescription api = unpacker.<ApiDescription> unpack(ApiDescription.class, reader, null)
        .getValue();
    logger.info("Retrieved API description with {} entities and {} endpoints", api.getEntities()
        .size(), api.getEndpoints().size());

    ServiceLoader<Dialect> loader = ServiceLoader.load(Dialect.class);
    for (Dialect d : loader) {
      if (d.getDialectName().equals(dialect)) {
        logger.info("Executing {} into {}", d.getClass().getCanonicalName(), out.getPath());
View Full Code Here

        new ObjectModelAdaptor() {
          @Override
          public Object getProperty(Interpreter interp, ST self, Object o,
              Object property, String propertyName)
              throws STNoSuchPropertyException {
            ApiDescription apiDescription = (ApiDescription) o;
            if ("endpoints".equals(propertyName)) {
              List<EndpointDescription> sortedEndpoints = new ArrayList<EndpointDescription>(
                  apiDescription.getEndpoints());
              Collections.sort(sortedEndpoints, new Comparator<EndpointDescription>() {
                @Override
                public int compare(EndpointDescription e1, EndpointDescription e2) {
                  return e1.getPath().compareTo(e2.getPath());
                }
              });
              return sortedEndpoints;
            }
            else if ("importNames".equals(propertyName)) {
              Set<String> imports = new HashSet<String>();
              for (EndpointDescription e : apiDescription.getEndpoints()) {
                if (e.getEntity() != null) {
                  String type = phpTypeForType(e.getEntity());
                  if (isRequiredImport(type)) {
                    imports.add(type);
                  }
View Full Code Here

TOP

Related Classes of com.getperka.flatpack.client.dto.ApiDescription

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.