AnnotationMetadata wsClientsAnnotation = cid.getAnnotation(ROO_WS_CLIENTS); AnnotationAttributeValue<?> currentEndpoints = wsClientsAnnotation.getAttribute("endpoints"); List<?> values = (List<?>) currentEndpoints.getValue(); && wsClientAnnotation.getValue().getAttribute("endpoint") != null) { if (wsClientAnnotation.getValue().getAttribute("endpoint").getValue() instanceof String) { endpointName = (String) wsClientAnnotation.getValue().getAttribute("endpoint").getValue(); Validate.notNull(endpointName, "'endpoint' attribute in @RooWsClient must be a String"); if (wsClientAnnotation.getValue().getAttribute("targetNamespace").getValue() instanceof String) { endpointNameSpace = (String) wsClientAnnotation.getValue().getAttribute("targetNamespace").getValue(); Validate.notNull(endpointName, "'targetNamespace' attribute in @RooWsClient must be a String"); if (wsClientAnnotation.getValue().getAttribute("binding").getValue() instanceof EnumDetails) { endpointBindingType = (EnumDetails) wsClientAnnotation.getValue().getAttribute("binding").getValue(); Validate.notNull(endpointBindingType, "'binding' attribute in @RooWsClient must be a SoapBindingType");
/** * Constructor * * @param annotationType the type of annotation for which these are the * metadata (required) * @param attributeValues the given annotation's values; can be * <code>null</code> */ DefaultAnnotationMetadata(final JavaType annotationType, final List<AnnotationAttributeValue<?>> attributeValues) { Validate.notNull(annotationType, "Annotation type required"); this.annotationType = annotationType; attributes = new ArrayList<AnnotationAttributeValue<?>>(); attributeMap = new HashMap<JavaSymbolName, AnnotationAttributeValue<?>>(); if (attributeValues != null) { attributes.addAll(attributeValues); for (final AnnotationAttributeValue<?> value : attributeValues) { attributeMap.put(value.getName(), value); } } }
getTypeLocationService().getTypeDetails(jsonController); AnnotationMetadata rooControllerAnnotation = controllerCid.getAnnotation(RooJavaType.ROO_CONTROLLER); if (rooControllerAnnotation == null) { LOGGER.warning(String.format("Ignoring %s of %s as missing %s annotation in %s", ROO_THYMELEAF_CONTROLLER_INTEGRATION_TEST.getSimpleTypeName(), governorPhysicalTypeMetadata.getType().getFullyQualifiedTypeName(), RooJavaType.ROO_CONTROLLER.getSimpleTypeName(), jsonController.getSimpleTypeName())); return null; Validate.notNull(rooControllerAnnotation.getAttribute("entity"), "The @RooController must have an 'entity' attribute, targeting managed entity."); final JavaType managedEntity = (JavaType) rooControllerAnnotation.getAttribute("entity").getValue(); JpaEntityMetadata.createIdentifier(getTypeLocationService().getTypeDetails(managedEntity)); JpaEntityMetadata entityMetadata = getMetadataService().get(jpaEntityIdentifier); if (entityMetadata == null) { entity.getSimpleTypeName(), this.getClass().getName())); } else { if (!relatedServices.contains(serviceDetails.getType())) { relatedServices.add(serviceDetails.getType());
getTypeLocationService().findClassesOrInterfaceDetailsWithAnnotation( ROO_READ_ONLY_REPOSITORY); getTypeLocationService().findClassesOrInterfaceDetailsWithAnnotation( ROO_REPOSITORY_JPA_CUSTOM); while (customRepositoriesIt.hasNext()) { ClassOrInterfaceTypeDetails customRepository = customRepositoriesIt.next(); AnnotationMetadata annotation = customRepository.getAnnotation(ROO_REPOSITORY_JPA_CUSTOM); if (annotation.getAttribute("entity").getValue().equals(entity)) { repositoryCustomList.add(customRepository.getType()); entity.equals(projectionAnnotation.getAttribute("entity").getValue()), "ERROR: %s defined on %s.@%s.defaultReturnType must be annotated with @%s annotation and match the 'entity' attribute value", annotationDefaultReturnType, governorPhysicalTypeMetadata.getType(), AnnotationAttributeValue<?> currentFinders = repositoryAnnotation.getAttribute("finders"); if (currentFinders != null) { List<?> values = (List<?>) currentFinders.getValue(); Iterator<?> valuesIt = values.iterator(); if (finderAnnotation.getValue().getAttribute("value").getValue() instanceof String) { finderName = (String) finderAnnotation.getValue().getAttribute("value").getValue(); new FinderMethod(returnType, new JavaSymbolName(finderName), Arrays.asList(new FinderParameter(formBean, new JavaSymbolName(StringUtils
@Override public String getBasePathForController(ClassOrInterfaceTypeDetails controller) { Validate.notNull(controller, "controller is required"); Validate.notNull(controller.getAnnotation(RooJavaType.ROO_CONTROLLER), "%s must be annotated with @%s", controller.getType(), RooJavaType.ROO_CONTROLLER.getSimpleTypeName()); ControllerAnnotationValues values = new ControllerAnnotationValues(controller); StringBuilder sbuilder = getBasePathStringBuilder(controller, values); // Before continue, check if the controller has a custom @RequestMapping annotation AnnotationMetadata requestMappingAnnotation = controller.getAnnotation(SpringJavaType.REQUEST_MAPPING); if (requestMappingAnnotation != null) { String customPath = ""; if (requestMappingAnnotation.getAttribute("value") != null) { String path = (String) requestMappingAnnotation.getAttribute("value").getValue(); // Only the base path should be returned customPath = path.split("\\{")[0]; if (customPath.endsWith("/")) { customPath = customPath.substring(0, customPath.length() - 1); } } // If some path has been specified and is different of the calculated one, return this one if (StringUtils.isNotEmpty(customPath) && !customPath.equals(sbuilder.toString())) { return customPath; } } return sbuilder.toString(); }
SoapBindingType bindingType, String serviceUrl, String profile) { configClassMemberDetails.getAnnotation(SpringJavaType.PROFILE); if (profileAnnotation != null) { String profiles = (String) profileAnnotation.getAttribute("value").getValue(); String[] definedProfiles = profiles.split(","); boolean profileExists = false; getApplicationConfigService().addProperty(configClass.getModule(), "url/".concat(endPoint), serviceUrl, profile, true); wsClientsAnnotation.build().getAttribute("endpoints"); List<?> values = (List<?>) existingEndPoints.getValue(); (NestedAnnotationAttributeValue) it.next(); String existingEndpointName = (String) existingEndPoint.getValue().getAttribute("endpoint").getValue(); if (existingEndpointName.equals(endPoint)) { alreadyManaged = true; (NestedAnnotationAttributeValue) iterator.next(); String existingEndpointName = (String) existingEndPoint.getValue().getAttribute("endpoint").getValue(); String existingEndpointNameSpace = (String) existingEndPoint.getValue().getAttribute("targetNamespace").getValue(); EnumDetails existingType = (EnumDetails) existingEndPoint.getValue().getAttribute("binding").getValue();
/** * * This method returns map controller by path * * @param typeLocationService * @return */ public static JavaType getMapControllerByPath(String path, TypeLocationService typeLocationService) { for (JavaType mapViewer : typeLocationService .findTypesWithAnnotation(MAP_VIEWER_ANNOTATION)) { Validate.notNull(mapViewer, "@GvNIXMapViewer required"); ClassOrInterfaceTypeDetails mapViewerController = typeLocationService .getTypeDetails(mapViewer); // Getting RequestMapping annotations final AnnotationMetadata requestMappingAnnotation = MemberFindingUtils .getAnnotationOfType(mapViewerController.getAnnotations(), SpringJavaType.REQUEST_MAPPING); Validate.notNull(mapViewer, String.format( "Error on %s getting @RequestMapping value", mapViewer)); String requestMappingPath = requestMappingAnnotation .getAttribute("value").getValue().toString(); String currentPath = requestMappingPath.toString().replaceAll("/", ""); if (currentPath.equals(path)) { return mapViewer; } } return null; }
String usernames) { Validate.notNull(klass, "ERROR: klass parameter is mandatory on 'generateAuthorizeAnnotations' method"); Validate.notNull(methodName, "ERROR: method parameter is mandatory on 'generateAuthorizeAnnotations' method"); getPushInOperations().pushIn(klass.getPackage(), klass, methodName, false); new NestedAnnotationAttributeValue(new JavaSymbolName("value"), getRooSecurityAuthorizationsAnnotation(method.getMethodName().getSymbolName(), lstParamTypes, roles, usernames).build()); ClassOrInterfaceTypeDetails serviceDetails = getTypeLocationService().getTypeDetails(klass); ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(serviceDetails); serviceDetails.getAnnotation(RooJavaType.ROO_SECURITY_AUTHORIZATIONS); AnnotationMetadataBuilder annotationAuthorizationsMetadataBuilder; annotationAuthorizations.getAttribute("authorizations"); List<?> values = (List<?>) attributeAuthorizations.getValue(); if (values != null && !values.isEmpty()) { Iterator<?> valuesIt = values.iterator(); getProjectOperations().addDependency(klass.getModule(), SPRING_SECURITY_CORE, false);
ClassOrInterfaceTypeDetails entityDetails = getTypeLocationService().getTypeDetails(entity); JavaType service = serviceDetails.getType(); final String serviceMetadataId = ServiceMetadata.createIdentifier(serviceDetails); registerDependency(serviceMetadataId, metadataIdentificationString); governorPhysicalTypeMetadata.getMemberHoldingTypeDetails().getName(); .getAnnotation(RooJavaType.ROO_DETAIL).getAttribute("relationField"); Validate.notNull(relationFieldAttr, "ERROR: In %s controller, @RooDetail annotation must have relationField value", controller); detailAnnotaionFieldValue = (String) relationFieldAttr.getValue(); Validate.isTrue(StringUtils.isNotBlank(detailAnnotaionFieldValue), "ERROR: In %s controller, @RooDetail annotation must have relationField value", controller);
.getTypeDetails(aspectName); if (controllerDetails == null) { return null; Validate.notNull( MemberFindingUtils.getAnnotationOfType(controllerDetails .getAnnotations(), new JavaType( "org.springframework.stereotype.Controller")), aspectName.getSimpleTypeName().concat( " has not @Controller annotation")); .getAnnotationOfType(controllerDetails.getAnnotations(), MODAL_DIALOGS); List<String> modalDialogsList = new ArrayList<String>(); .getAttribute(VALUE); .getValue();
Validate.notNull(targetType, targetType.getSimpleTypeName().concat(" doesn't exist in the project.")); final ClassOrInterfaceTypeDetails cid = getTypeLocationService().getTypeDetails(targetType); JpaEntityMetadata entityMetadata = getMetadataService().get(JpaEntityMetadata.createIdentifier(cid)); getTypeLocationService().findClassesOrInterfaceDetailsWithAnnotation( RooJavaType.ROO_JPA_ENTITY_FACTORY); Map<JavaType, JavaType> entityAndItsFactoryMap = new TreeMap<JavaType, JavaType>(); for (ClassOrInterfaceTypeDetails entityFactory : entityFactories) { JavaType entity = (JavaType) entityFactory.getAnnotation(RooJavaType.ROO_JPA_ENTITY_FACTORY) .getAttribute("entity").getValue(); if (entity != null && relatedEntities.contains(entity)) { entityAndItsFactoryMap.put(entity, entityFactory.getType());
/** * Get controller path from GvNIXMapViewer annotated controllers * * @param controller * @return */ private String getControllerPathFromViewerController(JavaType controller) { final ClassOrInterfaceTypeDetails cidController = getTypeLocationService() .getTypeDetails(controller); Validate.notNull(cidController, "The type specified, '%s', doesn't exist", cidController); // Only for @GvNIXMapViewer annotated controllers final AnnotationMetadata controllerAnnotation = MemberFindingUtils .getAnnotationOfType(cidController.getAnnotations(), new JavaType(GvNIXMapViewer.class.getName())); Validate.isTrue(controllerAnnotation != null, "Operation for @GvNIXMapViewer annotated controllers only."); String controllerPath = (String) cidController .getAnnotation(SpringJavaType.REQUEST_MAPPING) .getAttribute(VALUE).getValue(); controllerPath = controllerPath.replaceAll("/", "").trim(); return controllerPath; }
/** * Creates the Factory class of the child entity of relationship, only if parent entity has JPA unit tests. * * @param childType * @param parentType */ private void createChildEntityFactory(JavaType childType, JavaType parentType) { // Find current JPA unit tests Set<JavaType> unitTestTypes = typeLocationService.findTypesWithAnnotation(RooJavaType.ROO_JPA_UNIT_TEST); for (JavaType unitTestType : unitTestTypes) { // Get the annotation @RooJpaUnitTest ClassOrInterfaceTypeDetails cid = typeLocationService.getTypeDetails(unitTestType); AnnotationMetadata rooUnitTestAnnotation = cid.getAnnotation(RooJavaType.ROO_JPA_UNIT_TEST); // Check if parent entity has JPA unit test class AnnotationAttributeValue<Object> targetClass = rooUnitTestAnnotation.getAttribute("targetClass"); Validate.notNull(targetClass, String.format( "'targetClass' attribute can't be found for annotation @RooJpaUnitTest in class %s", unitTestType.getSimpleTypeName())); if (parentType.equals(targetClass.getValue())) { if (jpaEntityFactoryLocator.getFirstJpaEntityFactoryForEntity(childType) == null) { // Create factory class for child entity if doesn't exist dataOnDemandCreatorProvider.createEntityFactory(childType); } break; } } }
public void installFinder(final JavaType entity, final JavaSymbolName finderName, JavaType formBean, JavaType returnType) { Validate.notNull(entity, "ERROR: Entity type required to generate finder."); Validate.notNull(finderName, "ERROR: Finder name required to generate finder."); ClassOrInterfaceTypeDetails entityDetails = getTypeLocationService().getTypeDetails(entity); AnnotationMetadata entityAnnotation = entityDetails.getAnnotation(RooJavaType.ROO_JPA_ENTITY); Validate.notNull(entityAnnotation, "ERROR: Provided entity must be annotated with @RooJpaEntity"); repository.getAnnotation(RooJavaType.ROO_REPOSITORY_JPA); AnnotationMetadataBuilder repositoryAnnotationBuilder = new AnnotationMetadataBuilder(repositoryAnnotation); AnnotationAttributeValue<?> currentFinders = repositoryAnnotation.getAttribute("finders"); if (currentFinders != null) { List<?> values = (List<?>) currentFinders.getValue(); Iterator<?> it = values.iterator(); if (finder.getValue() != null && finder.getValue().getAttribute("value") != null) { if (finder.getValue().getAttribute("value").getValue().equals(finderName.getSymbolName())) { LOGGER.log( Level.WARNING, String.format("ERROR: Finder '%s' already exists on entity '%s'", finderName.getSymbolName(), entity.getSimpleTypeName())); return; if (returnType.getModule() != null) {
layerService = getLayerService(); Validate.notNull(layerService, "LayerService is required"); getTypeLocationService().findClassesOrInterfaceDetailsWithAnnotation( RooJavaType.ROO_JPA_ENTITY_FACTORY); JpaEntityFactoryMetadata entityFactoryMetadata = null; for (ClassOrInterfaceTypeDetails cid : entityFactoryClasses) { if (((JavaType) cid.getAnnotation(RooJavaType.ROO_JPA_ENTITY_FACTORY).getAttribute("entity") .getValue()).equals(entity)) { String entityFactoryIdentifier = JpaEntityFactoryMetadata.createIdentifier(cid); getTypeLocationService().findClassesOrInterfaceDetailsWithAnnotation( RooJavaType.ROO_JPA_DATA_ON_DEMAND_CONFIGURATION); if (dataOnDemandConfigurationClasses.isEmpty()) {
@Override public void addRepository(JavaType interfaceType, final JavaType domainType, JavaType defaultReturnType, boolean failOnComposition) { Validate.notNull(domainType, "ERROR: You must specify a valid Entity. "); ClassOrInterfaceTypeDetails entityDetails = getTypeLocationService().getTypeDetails(domainType); AnnotationMetadata entityAnnotation = entityDetails.getAnnotation(RooJavaType.ROO_JPA_ENTITY); getTypeLocationService().getTypeDetails(defaultReturnType); AnnotationMetadata defaultReturnTypeAnnotation = defaultReturnTypeDetails.getAnnotation(RooJavaType.ROO_ENTITY_PROJECTION); getTypeLocationService().findClassesOrInterfaceDetailsWithAnnotation( RooJavaType.ROO_REPOSITORY_JPA); existingRepository.getAnnotation(RooJavaType.ROO_REPOSITORY_JPA).getAttribute("entity"); if (relatedEntity.getValue().equals(domainType)) { LOGGER .log( entityDetails.getAnnotation(RooJavaType.ROO_JPA_ENTITY).getAttribute("readOnly"); boolean readOnly = readOnlyAttr != null && readOnlyAttr.getValue() ? true : false;
String profile, boolean force) { Validate.notNull(service, "ERROR: Provide a valid service"); Validate.notNull(sei, "ERROR: Provide a valid sei"); getTypeLocationService().getTypeDetails(service); Validate.notNull(serviceTypeDetails, "ERROR: Provide an existing service"); serviceTypeDetails.getAnnotation(RooJavaType.ROO_SERVICE); AnnotationAttributeValue<JavaType> entityAttr = serviceAnnotation.getAttribute("entity"); + "contains the 'entity' attribute"); JavaType relatedEntity = entityAttr.getValue(); new JavaType(String.format("%sEndpoint", sei.getFullyQualifiedTypeName()), sei.getModule()); configClassMemberDetails.getAnnotation(SpringJavaType.PROFILE); if (profileAnnotation != null) { String profiles = (String) profileAnnotation.getAttribute("value").getValue(); String[] definedProfiles = profiles.split(","); boolean profileExists = false; wsEndpointsAnnotation.build().getAttribute("endpoints"); List<?> values = (List<?>) existingEndPoints.getValue();
.notNull(klass, "ERROR: You must specify a valid class to continue with push-in action"); ClassOrInterfaceTypeDetails classDetails = getTypeLocationService().getTypeDetails(klass); Validate .notNull(klass, "ERROR: You must specify a valid class to continue with push-in action"); Validate.notNull(method, "ERROR: You must provide a valid method"); classDetails.getAnnotation(RooJavaType.ROO_JPA_UNIT_TEST) == null ? Path.SRC_MAIN_JAVA : Path.SRC_TEST_JAVA; getPathResolver().getPath(klass.getModule(), path)); classDetails.getAnnotation(RooJavaType.ROO_REPOSITORY_JPA_CUSTOM_IMPL); JavaType relatedRepositoryCustom = null; if (rooRepositoryCustomImplAnnotation != null) { AnnotationAttributeValue<Object> attribute = rooRepositoryCustomImplAnnotation.getAttribute("repository"); Validate.notNull(attribute, "Unable to find 'repository' attribute of @RooJpaRepositoryCustomImpl on '%s'", classDetails.getType().getSimpleTypeName()); relatedRepositoryCustom = (JavaType) attribute.getValue(); if (!memberHoldingTypeDetails.getType().equals(classDetails.getType())) { continue;
@Override protected ItdTypeDetailsProvidingMetadataItem getMetadata( final String metadataIdentificationString, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata, final String itdFilename) { // Getting annotated class details ClassOrInterfaceTypeDetails endpoint = governorPhysicalTypeMetadata.getMemberHoldingTypeDetails(); AnnotationMetadata seiImplAnnotation = endpoint.getAnnotation(ROO_SEI_IMPL); AnnotationAttributeValue<?> seiAttr = seiImplAnnotation.getAttribute(new JavaSymbolName("sei")); Validate.notNull(seiAttr, "ERROR: You must provide a valid SEI to be able to generate a Endpoint."); // Getting SEI from annotation JavaType seiType = (JavaType) seiAttr.getValue(); // Getting SEI details ClassOrInterfaceTypeDetails seiTypeDetails = getTypeLocationService().getTypeDetails(seiType); // Getting SEI Metadata final String seiMetadataId = SeiMetadata.createIdentifier(seiTypeDetails.getType(), PhysicalTypeIdentifier.getPath(seiTypeDetails.getDeclaredByMetadataId())); final SeiMetadata seiMetadata = (SeiMetadata) getMetadataService().get(seiMetadataId); // Getting SEI methods from service and save it Map<MethodMetadata, MethodMetadata> seiMethods = seiMetadata.getSeiMethods(); // Registering dependency between SeiMetadata and this one, to be able to // update Endpoint if SEI changes final String seiMetadataKey = SeiMetadata.createIdentifier(seiTypeDetails); registerDependency(seiMetadataKey, metadataIdentificationString); return new SeiImplMetadata(metadataIdentificationString, aspectName, governorPhysicalTypeMetadata, getProjectOperations().getTopLevelPackage(""), endpoint, seiType, seiMetadata.getService(), seiMethods); }
getTypeLocationService().getTypeDetails(serviceInterface); final ServiceMetadata serviceMetadata = getServiceMetadata(metadataIdentificationString, serviceInterfaceDetails); serviceInterfaceDetails.getAnnotation(RooJavaType.ROO_SERVICE); Validate.notNull(serviceAnnotation, "ERROR: Provided service should be annotated with @RooService"); JavaType entity = (JavaType) serviceAnnotation.getAttribute("entity").getValue(); ClassOrInterfaceTypeDetails entityDetails = getTypeLocationService().getTypeDetails(entity); final String entityMetadataId = JpaEntityMetadata.createIdentifier(entityDetails.getType(), PhysicalTypeIdentifier.getPath(entityDetails.getDeclaredByMetadataId())); final JpaEntityMetadata entityMetadata = (JpaEntityMetadata) getMetadataService().get(entityMetadataId); List<JavaType> types = new ArrayList<JavaType>(); types.add(method.getReturnType()); types.addAll(method.getReturnType().getParameters()); types.addAll(AnnotatedJavaType.convertFromAnnotatedJavaType(parameter).getParameters()); getTypeLocationService().addModuleDependency( governorPhysicalTypeMetadata.getType().getModule(), parameter);