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");
Validate.notNull(annotation, "Annotation required"); if (resolver.isFullyQualifiedFormRequiredAfterAutoImport(annotation.getAnnotationType())) { sb.append(annotation.getAnnotationType().getFullyQualifiedTypeName()); } else { sb.append(annotation.getAnnotationType().getSimpleTypeName()); sb.append(annotation.getAnnotationType().getFullyQualifiedTypeName()); if (annotation.getAttributeNames().isEmpty()) { return sb.toString(); for (final JavaSymbolName attributeName : annotation.getAttributeNames()) { final AnnotationAttributeValue<?> value = annotation.getAttribute(attributeName); if (!"value".equals(attributeName.getSymbolName()) || annotation.getAttributeNames().size() > 1) { sb.append(attributeName.getSymbolName()); sb.append(" = ");
/** * Constructor for using an existing {@link AnnotationMetadata} as a * baseline for building a new instance. * * @param existing required */ public AnnotationMetadataBuilder(final AnnotationMetadata existing) { Validate.notNull(existing); annotationType = existing.getAnnotationType(); for (final JavaSymbolName attributeName : existing.getAttributeNames()) { attributeValues.put(attributeName.getSymbolName(), existing.getAttribute(attributeName)); } this.setCommentStructure(existing.getCommentStructure()); }
private Map<String, Object> getAttributeMap(final FieldMetadata field) { final Map<String, Object> map = new HashMap<String, Object>(); final AnnotationMetadata annotationMetadata = getMatchingAnnotation(field); if (annotationMetadata != null) { for (final JavaSymbolName attributeName : annotationMetadata.getAttributeNames()) { map.put(attributeName.getSymbolName(), annotationMetadata.getAttribute(attributeName) .getValue()); } } return map; }
private String getSuffix(final List<MemberHoldingTypeDetails> memberHoldingTypeDetailsList, final boolean singular, final Map<String, String> pluralMap) { final ClassOrInterfaceTypeDetails cid = getMostConcreteClassOrInterfaceTypeDetails(memberHoldingTypeDetailsList); if (singular) { return cid.getName().getSimpleTypeName(); } String plural = pluralMap.get(cid.getDeclaredByMetadataId()); for (final AnnotationMetadata annotationMetadata : cid.getAnnotations()) { if (annotationMetadata.getAnnotationType().getFullyQualifiedTypeName() .equals(ROO_PLURAL.getFullyQualifiedTypeName())) { final AnnotationAttributeValue<?> annotationAttributeValue = annotationMetadata.getAttribute(new JavaSymbolName("value")); if (annotationAttributeValue != null) { plural = annotationAttributeValue.getValue().toString(); } break; } } if (StringUtils.isNotBlank(plural)) { plural = StringUtils.capitalize(plural); } return plural; }
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(); (NestedAnnotationAttributeValue) valuesIt.next(); if (finderAnnotation.getValue() != null && finderAnnotation.getValue().getAttribute("value") != null) { if (finderAnnotation.getValue().getAttribute("value").getValue() instanceof String) { finderName = (String) finderAnnotation.getValue().getAttribute("value").getValue();
@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(); }
/** * Constructor must contain {@link FieldMetadata} of existing field (may * already contain field annotations) and a list of new Annotations which * should be introduced by an AspectJ ITD. The added annotations can not * already be present in {@link FieldMetadata}. * * @param field FieldMetadata of existing field (may not be null) * @param fieldAnnotation Annotation to be added to field via an ITD (may * not be null) * @param removeAnnotation if true, will cause the specified annotation to * be REMOVED via AspectJ's "-" syntax (usually would be false) */ public DeclaredFieldAnnotationDetails(final FieldMetadata field, final AnnotationMetadata fieldAnnotation, final boolean removeAnnotation) { Validate.notNull(field, "Field metadata required"); Validate.notNull(fieldAnnotation, "Field annotation required"); if (removeAnnotation) { Validate .isTrue( fieldAnnotation.getAttributeNames().isEmpty(), "Field annotation '@%s' (on target field %s.%s) must not have any attributes when requesting its removal", fieldAnnotation.getAnnotationType().getSimpleTypeName(), field.getFieldType() .getFullyQualifiedTypeName(), field.getFieldName().getSymbolName()); } this.field = field; this.fieldAnnotation = fieldAnnotation; this.removeAnnotation = removeAnnotation; }
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);
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);
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) {
/** * 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; } } }
.notNull(klass, "ERROR: You must specify a valid class to continue with push-in action"); classDetails.getAnnotation(RooJavaType.ROO_JPA_UNIT_TEST) == null ? Path.SRC_MAIN_JAVA : Path.SRC_TEST_JAVA; getPathResolver().getPath(klass.getModule(), path)); if (!memberHoldingTypeDetails.getType().equals(classDetails.getType())) { continue; .getFullyQualifiedTypeName()) && !method.getDeclaredByMetadataId().equals(declaredByMetadataId)) { classDetails = getTypeLocationService().getTypeDetails(detailsBuilder.build().getType()); for (AnnotationMetadata annotation : allDeclaredAnnotations) { classDetails = getTypeLocationService().getTypeDetails(detailsBuilder.build().getType()); List<AnnotationMetadata> javaDeclaredAnnotations = classDetails.getAnnotations(); boolean annotationExists = false; for (AnnotationMetadata javaAnnotation : javaDeclaredAnnotations) { if (javaAnnotation.getAnnotationType().getFullyQualifiedTypeName() .equals(annotation.getAnnotationType().getFullyQualifiedTypeName())) { annotationExists = true; changesToApply.append(String.format( "Annotation '%s' will be pushed on '%s.java' class. \n", annotation .getAnnotationType().getSimpleTypeName(), klass.getSimpleTypeName()));
@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();
Validate.notNull(target, "Target required"); final JavaSymbolName attributeName = new JavaSymbolName(attribute); if (annotation.getAttributeNames().contains(attributeName)) { final AnnotationAttributeValue<?> value = annotation.getAttribute(attributeName); if (value instanceof BooleanAttributeValue && (fieldType.equals(Boolean.class) || fieldType.equals(Boolean.TYPE))) { field.set(target, value.getValue()); } else if (value instanceof CharAttributeValue && (fieldType.equals(Character.class) || fieldType.equals(Character.TYPE))) { field.set(target, value.getValue()); } else if (value instanceof ClassAttributeValue && fieldType.equals(JavaType.class)) { field.set(target, value.getValue()); } else if (value instanceof DoubleAttributeValue && (fieldType.equals(Double.class) || fieldType.equals(Double.TYPE))) {
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());
.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;
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());
@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); }