use of com.linkedin.restli.restspec.AssociationSchema in project rest.li by linkedin.
the class TestExamplesGenerator method findFinder.
private static FinderSchema findFinder(ResourceSchema resourceSchema, String finderName) {
final CollectionSchema collectionSchema = resourceSchema.getCollection();
if (collectionSchema != null) {
final FinderSchemaArray finders = collectionSchema.getFinders();
if (finders != null) {
for (FinderSchema finderSchema : finders) {
if (finderSchema.getName().equals(finderName)) {
return finderSchema;
}
}
}
}
final AssociationSchema associationSchema = resourceSchema.getAssociation();
if (associationSchema != null) {
final FinderSchemaArray finders = associationSchema.getFinders();
if (finders != null) {
for (FinderSchema finderSchema : finders) {
if (finderSchema.getName().equals(finderName)) {
return finderSchema;
}
}
}
}
return null;
}
use of com.linkedin.restli.restspec.AssociationSchema in project rest.li by linkedin.
the class TestExamplesGenerator method findCollectionAction.
private static ActionSchema findCollectionAction(ResourceSchema resourceSchema, String actionName) {
final CollectionSchema collectionSchema = resourceSchema.getCollection();
if (collectionSchema != null) {
final ActionSchemaArray actions = collectionSchema.getActions();
if (actions != null) {
for (ActionSchema actionSchema : actions) {
if (actionSchema.getName().equals(actionName)) {
return actionSchema;
}
}
}
}
final AssociationSchema associationSchema = resourceSchema.getAssociation();
if (associationSchema != null) {
final ActionSchemaArray actions = associationSchema.getActions();
if (actions != null) {
for (ActionSchema actionSchema : actions) {
if (actionSchema.getName().equals(actionName)) {
return actionSchema;
}
}
}
}
return null;
}
use of com.linkedin.restli.restspec.AssociationSchema in project rest.li by linkedin.
the class TestExamplesGenerator method findEntityAction.
private static ActionSchema findEntityAction(ResourceSchema resourceSchema, String actionName) {
ActionSchema actionSchema;
final CollectionSchema collectionSchema = resourceSchema.getCollection();
if (collectionSchema != null) {
final EntitySchema entity = collectionSchema.getEntity();
if (entity != null) {
actionSchema = findActionInEntity(entity, actionName);
if (actionSchema != null) {
return actionSchema;
}
}
}
final AssociationSchema associationSchema = resourceSchema.getAssociation();
if (associationSchema != null) {
final EntitySchema entity = associationSchema.getEntity();
if (entity != null) {
actionSchema = findActionInEntity(entity, actionName);
if (actionSchema != null) {
return actionSchema;
}
}
}
return null;
}
use of com.linkedin.restli.restspec.AssociationSchema in project rest.li by linkedin.
the class ResourceModelEncoder method appendCollection.
private void appendCollection(final ResourceSchema resourceSchema, final ResourceModel collectionModel) {
appendCommon(collectionModel, resourceSchema);
CollectionSchema collectionSchema = new CollectionSchema();
//HACK: AssociationSchema and CollectionSchema share many common elements, but have no inheritance
//relationship. Here, we construct them both as facades on the same DataMap, which allows
//us to pass strongly typed CollectionSchema objects around, even when we're dealing with
//an association.
AssociationSchema associationSchema = new AssociationSchema(collectionSchema.data());
if (collectionModel.getKeys().size() == 1) {
appendIdentifierNode(collectionSchema, collectionModel);
} else {
appendKeys(associationSchema, collectionModel);
}
appendAlternativeKeys(collectionSchema, collectionModel);
appendSupportsNodeToCollectionSchema(collectionSchema, collectionModel);
appendMethodsToCollectionSchema(collectionSchema, collectionModel);
FinderSchemaArray finders = createFinders(collectionModel);
if (finders.size() > 0) {
collectionSchema.setFinders(finders);
}
ActionSchemaArray actions = createActions(collectionModel, ResourceLevel.COLLECTION);
if (actions.size() > 0) {
collectionSchema.setActions(actions);
}
appendEntityToCollectionSchema(collectionSchema, collectionModel);
switch(collectionModel.getResourceType()) {
case COLLECTION:
resourceSchema.setCollection(collectionSchema);
break;
case ASSOCIATION:
resourceSchema.setAssociation(associationSchema);
break;
default:
throw new IllegalArgumentException("unsupported resource type");
}
}
use of com.linkedin.restli.restspec.AssociationSchema in project rest.li by linkedin.
the class SnapshotGenerator method findModelsAssocation.
private void findModelsAssocation(ResourceSchema resourceSchema, Map<String, NamedDataSchema> foundTypes, List<NamedDataSchema> typeOrder) {
AssociationSchema association = resourceSchema.getAssociation();
if (association != null) {
for (AssocKeySchema assocKeySchema : association.getAssocKeys()) {
String type = assocKeySchema.getType();
recordType(type, foundTypes, typeOrder);
}
if (association.hasFinders()) {
for (FinderSchema restMethodSchema : association.getFinders()) {
findModelsFinder(restMethodSchema, foundTypes, typeOrder);
}
}
if (association.hasMethods()) {
for (RestMethodSchema restMethodSchema : association.getMethods()) {
findModelsMethod(restMethodSchema, foundTypes, typeOrder);
}
}
if (association.hasActions()) {
for (ActionSchema actionSchema : association.getActions()) {
findModelsAction(actionSchema, foundTypes, typeOrder);
}
}
if (association.hasEntity()) {
EntitySchema entitySchema = association.getEntity();
findModelsEntity(entitySchema, foundTypes, typeOrder);
}
}
}
Aggregations