0
votes

Ive been trying to use breeze with third party RESTful API - the API expects parameters of two types - deep linking like - localhost/request/5 for single entities (ie. request with id = 5) and parametrised queries using JSON encoded in URL (transformed by breeze with no problem).

The main problem is to make breeze to create request with URL such as: localhost/request/{id}

not JSON encoded GET, while using breeze query "withParameters( {workorderid: id})"

And the second part of problem is using syntax like:

 var query = breeze.EntityQuery
   .from('request')
   .withParameters(parameters)
   .expand('requestDetails');

To query for two entities - main - request - and secondary - requestDetails (with deffered on access querying for value of the secondary object).

The result should be like on this image:

http://postimg.org/image/prurk75ol/

My model is defined by hand with two entities:

metadataStore.addEntityType({
  shortName: "request",
  namespace: "servicedesk",
  dataProperties: {
    workorderid: {
      dataType: DT.Identity,
      isPartOfKey: true
    },
    ignorerequest: {
      dataType: DT.Boolean
    }
  },
  navigationProperties: {
    requestDetails: {
      entityTypeName: "requestDetails:#servicedesk",
      isScalar: true,
      associationName: "request_requestDetails",
      foreignKeyNames: ["workorderid"]
    }
  }
});

metadataStore.addEntityType({
      shortName: "requestDetails",
      namespace: "servicedesk",
      dataProperties: {
        workorderid: {
          dataType: DT.Identity,
          isPartOfKey: true
        },
        group: {
          dataType: DT.String
        },
        description: {
          dataType: DT.String
        }
      },
      navigationProperties: {
        request: {
          entityTypeName: "request:#servicedesk",
          isScalar: true,
          associationName: "requestDetails_request",
          foreignKeyNames: ["workorderid"]
        }
      }

Ive found example of this: https://github.com/Breeze/breeze.js.labs/blob/master/breeze.ajaxrestinterceptor.js , it looks like i can change url generation by intercepting ajax calls, can this be done for angular.breeze adapter?

1

1 Answers

0
votes

I don't fully understand your question. What query are you having trouble with? Please edit your answer so we can help.

BUT I do see what looks like a metadata problem with your definition of the request type's requestDetails navigation property. Both the property name and the semantics suggest this should return a collection but you've defined it as a scalar.

requestDetails: {
  entityTypeName: "requestDetails:#servicedesk",
  isScalar: true, // <-- HUH?
  associationName: "request_requestDetails",
  foreignKeyNames: ["workorderid"]
}

I think you want isScalar: false,