当前位置: 首页>>代码示例>>Java>>正文


Java Resource类代码示例

本文整理汇总了Java中org.raml.model.Resource的典型用法代码示例。如果您正苦于以下问题:Java Resource类的具体用法?Java Resource怎么用?Java Resource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Resource类属于org.raml.model包,在下文中一共展示了Resource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldFlattenResourceList

import org.raml.model.Resource; //导入依赖的package包/类
@Test
public void shouldFlattenResourceList() throws Exception {
    final Raml raml = new Raml();

    final Resource usersResource = new Resource();
    final Resource userResource = new Resource();
    final Resource userSettingsResource = new Resource();

    usersResource.getResources().put("/{userId}", userResource);
    userResource.getResources().put("/settings", userSettingsResource);

    raml.getResources().put("/users", usersResource);

    final List<Resource> flattenned = ResourceList.of(Lists.newArrayList(usersResource))
            .flatten()
            .collect(toList());

    assertThat(flattenned, containsInAnyOrder(usersResource, userResource, userSettingsResource));
}
 
开发者ID:hubrick,项目名称:raml-maven-plugin,代码行数:20,代码来源:ResourceListTest.java

示例2: buildTemplate

import org.raml.model.Resource; //导入依赖的package包/类
private String buildTemplate() {
	Resource oResource=action.getResource();
	String oUrl=oResource.getRelativeUri();
	while(oResource.getParentResource()!=null) {
		oResource=oResource.getParentResource();
		oUrl=oResource.getRelativeUri()+oUrl;
	}
	if(!Utils.hasBeenResolved(root.getBaseUri())) {
		oUrl=root.getBaseUri()+oUrl;
	}
	oResource=action.getResource();
	while(oResource!=null) {
		oUrl=Resolver.resolve(oUrl, oResource.getUriParameters(), "[UriParameter]");
		oResource=oResource.getParentResource();
	}
	return oUrl;
}
 
开发者ID:pagesjaunes,项目名称:raml-codegen,代码行数:18,代码来源:ActionAdaptator.java

示例3: createDataObject

import org.raml.model.Resource; //导入依赖的package包/类
private void createDataObject(Resource resource, DataObjectInfo parentDataObject, Resource parentResource)
{
  String name = extractResourceNameFromUriPath(resource);
  // name can be null when it is  top-level resource consisting of only a slask, or only uri params
  // which should be very unlikely
  name = name==null ? "Root" : name;
  DataObjectInfo doi = new DataObjectInfo(name, resource.getUri());
  doi.setXmlPayload(false);
  dataObjectInfos.add(doi);

  // loop over the various actions (HTTP Verbs) of the resource
  // if the action is GET , we process the REQUEST body and add the attributes
  // found in the request example or request schema reference. The GET resource is also set as
  // findALl method/ If a nested GET resource is found with the path consisting entirely of a path param,
  // we assume this is the "getCanonical" resource. The sample/schema attributes of this nested GET resource
  // will also be added to the data object.
  // if it is a non-GET action, we process the RESPONSE with code 200 or 201 and add the attributes found
  // in the response example or response schema reference
  processResourceActions(resource, doi, parentDataObject, false);
  // loop over nested resources. If the whole nested resource path just consist of uri parameters, and
  // no additional naming, we treat this as additional resources for the current data object, otherwise
  // we treat it as a child resource and we make a recursive call to create new child data object
  processNestedResources(resource, parentDataObject, doi); 
}
 
开发者ID:oracle,项目名称:mobile-persistence,代码行数:25,代码来源:RAMLParser.java

示例4: processNestedResources

import org.raml.model.Resource; //导入依赖的package包/类
private void processNestedResources(Resource resource, DataObjectInfo parentDataObject, DataObjectInfo doi)
{
  Map<String, Resource> nestedResources = resource.getResources();
  for (Resource nestedResource : nestedResources.values())
  {
    boolean pathOnlyContainsParams = checkPathOnlyContainsParams(nestedResource);
    if (pathOnlyContainsParams)
    {
      processResourceActions(nestedResource, doi, parentDataObject, true);
      // make recursive call to walk down resource tree
      processNestedResources(nestedResource, parentDataObject, doi);
    }
    else
    {
      // child resource, recursive call to processNestedResources is made inside createDataObject
      createDataObject(nestedResource, doi, resource);
    }
  }
}
 
开发者ID:oracle,项目名称:mobile-persistence,代码行数:20,代码来源:RAMLParser.java

示例5: processResourceActions

import org.raml.model.Resource; //导入依赖的package包/类
private void processResourceActions(Resource resource, DataObjectInfo doi, DataObjectInfo parentDataObject, boolean isNestedResource)
{
  Map<ActionType, Action> actions = resource.getActions();
  for (ActionType actionType: actions.keySet())
  {
    Action action = actions.get(actionType);
    if ("GET".equalsIgnoreCase(actionType.name()))
    {
      processGETResponse(resource, doi, parentDataObject, action, isNestedResource);
    }
    else
    {
      processNonGETRequest(resource, doi, parentDataObject, action);
    }
  }
}
 
开发者ID:oracle,项目名称:mobile-persistence,代码行数:17,代码来源:RAMLParser.java

示例6: checkPathOnlyContainsParams

import org.raml.model.Resource; //导入依赖的package包/类
private boolean checkPathOnlyContainsParams(Resource childResource)
{
  String uri = childResource.getRelativeUri();
  // replace all params and their enclosing curly brackets with emmpty string
  // also replace "/" with empty string, the remainder is the name, which can be 
  // an empty string if path consists entirely of uri params
  uri = StringUtils.substitute(uri, "/", "");
  Map<String, UriParameter> params = childResource.getUriParameters();
  for (String paramName : params.keySet())
  {
    uri = StringUtils.substitute(uri, "{"+paramName+"}", "");
  }
  if (uri.trim().equals(""))
  {
    uri=null;
  }
  return uri==null;
}
 
开发者ID:oracle,项目名称:mobile-persistence,代码行数:19,代码来源:RAMLParser.java

示例7: register

import org.raml.model.Resource; //导入依赖的package包/类
private void register(final Resource resource)
{
	final Map<String, ?> methods = getMap(collector, resource.getUri());

	final List<String> rIs = resource.getIs();

	resource.getActions().values().stream().forEach(a -> {
		final Map<String, ?> attributes = getMap(methods, a.getType().toString());

		// a.getIs().forEach(i -> addValue(attributes, "request.is." + i, "true"));
		// rIs.forEach(i -> addValue(attributes, "request.is." + i, "true"));

		a.getQueryParameters().entrySet().forEach(q -> addValue(attributes, "request.query." + q.getKey(),
				q.getValue().getExample(), q.getValue().getDefaultValue()));

		a.getResponses().entrySet().forEach(r -> {
			addValue(attributes, "response.status", r.getKey());
			r.getValue().getHeaders().entrySet().forEach(h -> addValue(attributes, "response.header." + h.getKey(),
					h.getValue().getExample(), h.getValue().getDefaultValue()));
		});

		a.getHeaders().entrySet().forEach(h -> addValue(attributes, "request.header." + h.getKey(),
				h.getValue().getExample(),
				h.getValue().getDefaultValue()));
	});
}
 
开发者ID:marekasf,项目名称:raml-validation-proxy,代码行数:27,代码来源:RamlParser.java

示例8: getResourceMapping

import org.raml.model.Resource; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected static Map<String, Object> getResourceMapping(Resource resource) {
	Map<String, Object> map = (Map<String, Object>) Generator.currentRamlMap;
	List<String> keys = getResourcePaths(resource);
	String uri = null;

	for (String key : keys) {
		if (StringUtils.isEmpty(key)) {
			continue;
		}
		
		uri = key;
		map = (Map<String, Object>) map.get(key);
	}
	
	map.put("uri", uri);
	return map;
}
 
开发者ID:aureliano,项目名称:cgraml-maven-plugin,代码行数:19,代码来源:RamlHelper.java

示例9: getResourcePaths

import org.raml.model.Resource; //导入依赖的package包/类
private static List<String> getResourcePaths(Resource resource) {
	List<String> paths = new ArrayList<String>();
	String uri = resource.getUri();
	
	Resource parent = resource.getParentResource();
	if (parent != null) {
		for (String path : getResourcePaths(parent)) {
			paths.add(path);
		}
		uri = uri.replace(parent.getUri(), "");
	}
	
	paths.add(uri);
	
	return paths;
}
 
开发者ID:aureliano,项目名称:cgraml-maven-plugin,代码行数:17,代码来源:RamlHelper.java

示例10: traverse

import org.raml.model.Resource; //导入依赖的package包/类
public void traverse() {
  notifyStartTraversal();
  notifyStartApiInformation();

  for (final Map.Entry<String, Resource> resource : raml.getResources().entrySet()) {
    eachListener(new ListenerFunction() {
      @Override
      public void apply(RamlTraversalListener listener) {
        listener.startResource(resource.getKey(), resource.getValue());
        // ACTIONS etc.
        listener.endResource(resource.getKey(), resource.getValue());
      }
    });
  }

  notifyEndTraversal();
}
 
开发者ID:adrobisch,项目名称:raml-converter,代码行数:18,代码来源:RamlTraversal.java

示例11: addProjectEndpoints

import org.raml.model.Resource; //导入依赖的package包/类
/**
 * Add all project verticles to the list resources.
 * 
 * @param resources
 * @throws IOException
 * @throws Exception
 */
private void addProjectEndpoints(Map<String, Resource> resources) throws IOException {
	NodeEndpoint nodeEndpoint = Mockito.spy(new NodeEndpoint());
	initEndpoint(nodeEndpoint);
	String projectBasePath = "/{project}";
	addEndpoints(projectBasePath, resources, nodeEndpoint);

	TagFamilyEndpoint tagFamilyEndpoint = Mockito.spy(new TagFamilyEndpoint());
	initEndpoint(tagFamilyEndpoint);
	addEndpoints(projectBasePath, resources, tagFamilyEndpoint);

	NavRootEndpoint navEndpoint = Mockito.spy(new NavRootEndpoint());
	initEndpoint(navEndpoint);
	addEndpoints(projectBasePath, resources, navEndpoint);

	WebRootEndpoint webEndpoint = Mockito.spy(new WebRootEndpoint());
	initEndpoint(webEndpoint);
	addEndpoints(projectBasePath, resources, webEndpoint);

	ReleaseEndpoint releaseEndpoint = Mockito.spy(new ReleaseEndpoint());
	initEndpoint(releaseEndpoint);
	addEndpoints(projectBasePath, resources, releaseEndpoint);

	GraphQLEndpoint graphqlEndpoint = Mockito.spy(new GraphQLEndpoint());
	initEndpoint(graphqlEndpoint);
	addEndpoints(projectBasePath, resources, graphqlEndpoint);

	ProjectSearchEndpointImpl projectSearchEndpoint = Mockito.spy(new ProjectSearchEndpointImpl());
	initEndpoint(projectSearchEndpoint);
	addEndpoints(projectBasePath, resources, projectSearchEndpoint);

	ProjectSchemaEndpoint projectSchemaEndpoint = Mockito.spy(new ProjectSchemaEndpoint());
	initEndpoint(projectSchemaEndpoint);
	addEndpoints(projectBasePath, resources, projectSchemaEndpoint);

	ProjectMicroschemaEndpoint projectMicroschemaEndpoint = Mockito.spy(new ProjectMicroschemaEndpoint());
	initEndpoint(projectMicroschemaEndpoint);
	addEndpoints(projectBasePath, resources, projectMicroschemaEndpoint);

}
 
开发者ID:gentics,项目名称:mesh,代码行数:47,代码来源:RAMLGenerator.java

示例12: baseResource

import org.raml.model.Resource; //导入依赖的package包/类
public static MethodSpec baseResource(Resource resource, String basePackage, String confFName, String reqSupplFName) {
    return MethodSpec.methodBuilder(uncapitalize(classPart(resource)))
            .returns(ClassName.get(basePackage + "." + packageName(resource), className(resource)))
            .addStatement("return new $N($N.$N.get())", className(resource), confFName, reqSupplFName)
            .addModifiers(PUBLIC)
            .build();
}
 
开发者ID:qameta,项目名称:rarc,代码行数:8,代码来源:NextResourceMethods.java

示例13: childResource

import org.raml.model.Resource; //导入依赖的package包/类
public static MethodSpec childResource(Resource resource, String basePackage, String reqSpecFName) {
    String methodName = uncapitalize(classPart(resource));
    
    return MethodSpec.methodBuilder(methodName)
            .returns(ClassName.get(basePackage + "." + packageName(resource), className(resource)))
            .addStatement("return new $N($N)", className(resource), reqSpecFName)
            .addModifiers(PUBLIC)
            .build();
}
 
开发者ID:qameta,项目名称:rarc,代码行数:10,代码来源:NextResourceMethods.java

示例14: forResource

import org.raml.model.Resource; //导入依赖的package包/类
public static ApiResourceClass forResource(Resource resource) {
    ApiResourceClass apiClass = new ApiResourceClass();
    apiClass.resource = resource;
    apiClass.packageName = packageName(resource);
    apiClass.className = className(resource);
    return apiClass;
}
 
开发者ID:qameta,项目名称:rarc,代码行数:8,代码来源:ApiResourceClass.java

示例15: classPart

import org.raml.model.Resource; //导入依赖的package包/类
public static String classPart(Resource resource) {
    if (resource == null) {
        return "";
    }

    String name = isNotEmpty(resource.getDisplayName())
            ? sanitize(resource.getDisplayName())
            : sanitize(resource.getRelativeUri())
            .replace(".", "");

    return capitalize(name.contains("/") ? substringAfterLast(name, "/") : name);
}
 
开发者ID:qameta,项目名称:rarc,代码行数:13,代码来源:ApiResourceClass.java


注:本文中的org.raml.model.Resource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。