Example #1
0
  void appendServicePathsAndDefinitions() {
    // take copy to avoid concurrent modification exception
    final Collection<ObjectSpecification> allSpecs =
        Lists.newArrayList(specificationLoader.allSpecifications());
    for (final ObjectSpecification serviceSpec : allSpecs) {

      final DomainServiceFacet domainServiceFacet = serviceSpec.getFacet(DomainServiceFacet.class);
      if (domainServiceFacet == null) {
        continue;
      }
      if (visibility.isPublic()
          && domainServiceFacet.getNatureOfService() != NatureOfService.VIEW_REST_ONLY) {
        continue;
      }
      if (domainServiceFacet.getNatureOfService() != NatureOfService.VIEW_MENU_ONLY
          && domainServiceFacet.getNatureOfService() != NatureOfService.VIEW
          && domainServiceFacet.getNatureOfService() != NatureOfService.VIEW_REST_ONLY) {
        continue;
      }

      final List<ObjectAction> serviceActions =
          Util.actionsOf(serviceSpec, visibility, classExcluder);
      if (serviceActions.isEmpty()) {
        continue;
      }
      appendServicePath(serviceSpec);

      for (final ObjectAction serviceAction : serviceActions) {
        appendServiceActionInvokePath(serviceSpec, serviceAction);
      }
    }
  }
Example #2
0
  void appendObjectPathsAndDefinitions() {
    // take copy to avoid concurrent modification exception
    final Collection<ObjectSpecification> allSpecs =
        Lists.newArrayList(specificationLoader.allSpecifications());
    for (final ObjectSpecification objectSpec : allSpecs) {

      final DomainServiceFacet domainServiceFacet = objectSpec.getFacet(DomainServiceFacet.class);
      if (domainServiceFacet != null) {
        continue;
      }
      final MixinFacet mixinFacet = objectSpec.getFacet(MixinFacet.class);
      if (mixinFacet != null) {
        continue;
      }
      if (visibility.isPublic() && !Util.isVisibleForPublic(objectSpec)) {
        continue;
      }
      if (objectSpec.isAbstract()) {
        continue;
      }
      if (objectSpec.isValue()) {
        continue;
      }
      // special cases
      if (classExcluder.exclude(objectSpec)) {
        continue;
      }

      final List<OneToOneAssociation> objectProperties = Util.propertiesOf(objectSpec, visibility);
      final List<OneToManyAssociation> objectCollections =
          Util.collectionsOf(objectSpec, visibility);
      final List<ObjectAction> objectActions =
          Util.actionsOf(objectSpec, visibility, classExcluder);

      if (objectProperties.isEmpty() && objectCollections.isEmpty()) {
        continue;
      }
      final ModelImpl isisModel = appendObjectPathAndModelDefinitions(objectSpec);
      updateObjectModel(isisModel, objectSpec, objectProperties, objectCollections);

      for (final OneToManyAssociation objectCollection : objectCollections) {
        appendCollectionTo(objectSpec, objectCollection);
      }

      for (final ObjectAction objectAction : objectActions) {
        appendObjectActionInvokePath(objectSpec, objectAction);
      }
    }
  }
 public static ObjectSpecification getSpecification(
     final SpecificationLoader specificationLookup, final Class<?> type) {
   return type == null ? null : specificationLookup.loadSpecification(type);
 }