ClassOrInterfaceTypeDetails cid = typeLocationService.getTypeDetails(type); Validate.notNull(cid.getAnnotation(RooJavaType.ROO_REPOSITORY_JPA), "Type must be a Roo JPA Repository type."); new JavaType(managedEntity.getFullyQualifiedTypeName(), managedEntity.getArray(), managedEntity.getDataType(), managedEntity.getArgName(), managedEntity.getParameters(), typeLocationService.getTypeDetails(managedEntity).getType().getModule()); final JavaType name = new JavaType(type + "IT", module.getModuleName()); final String declaredByMetadataId = PhysicalTypeIdentifier.createIdentifier(name, Path.SRC_TEST_JAVA.getModulePathId(module.getModuleName())); if (metadataService.get(declaredByMetadataId) != null) { new AnnotationMetadataBuilder(RooJavaType.ROO_REPOSITORY_JPA_INTEGRATION_TEST); rooIntegrationTestAnnotation.addClassAttribute("targetClass", type); rooIntegrationTestAnnotation.addClassAttribute("dodConfigurationClass", creator.getDataOnDemandConfiguration()); rooIntegrationTestAnnotation.addClassAttribute("dodClass", new ClassOrInterfaceTypeDetailsBuilder(declaredByMetadataId, Modifier.PUBLIC, name, PhysicalTypeCategory.CLASS); cidBuilder.addAnnotation(rooIntegrationTestAnnotation); typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build());
values = new EntityDeserializerAnnotationValues(deserializer); if (entity.equals(values.getEntity())) { new JavaType(String.format("%s.%sDeserializer", getTypeLocationService().getPhysicalTypeCanonicalPath(deserializerClass, deserializerPath); final String declaredByMetadataIdItem = PhysicalTypeIdentifier.createIdentifier(deserializerClass, getPathResolver().getPath(resourceIdentifierItem)); ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(declaredByMetadataIdItem, Modifier.PUBLIC, deserializerClass, PhysicalTypeCategory.CLASS); cidBuilder.setAnnotations(annotations); cidBuilder.addExtendsTypes(JavaType.wrapperOf(JSON_OBJECT_DESERIALIZER, entity)); serviceDetails.getType()); FieldMetadata conversionServiceField = EntityDeserializerMetadata.getFieldFor(declaredByMetadataIdItem, SpringJavaType.CONVERSION_SERVICE); cidBuilder.addField(serviceField); cidBuilder.addField(conversionServiceField); cidBuilder.addConstructor(constructor); getTypeManagementService().createOrUpdateTypeOnDisk(cidBuilder.build());
new AnnotationMetadataBuilder(RooJavaType.ROO_EXCEPTION_HANDLER); ERROR_VIEW), errorView)); exceptionHandlerAnnotationBuilder.setAttributes(exceptionHandlerAnnotationAttributes); ClassOrInterfaceTypeDetails typeDetails = typeLocationService.getTypeDetails(targetClass); ClassOrInterfaceTypeDetailsBuilder typeDetailsBuilder = new ClassOrInterfaceTypeDetailsBuilder(typeDetails); AnnotationMetadata exceptionHandlersAnnotation = typeDetails.getAnnotation(RooJavaType.ROO_EXCEPTION_HANDLERS); new AnnotationMetadataBuilder(exceptionHandlersAnnotation); } else { exceptionHandlersAnnotationBuilder = exceptionHandlersAnnotationBuilder.setAttributes(attributeValues); typeDetailsBuilder.addAnnotation(exceptionHandlersAnnotationBuilder.build()); } else { LOGGER.warning(String.format( "There is already a handler for exception %s in class %s", exception.getSimpleTypeName(), targetClass.getSimpleTypeName())); return; typeDetailsBuilder.updateTypeAnnotation(exceptionHandlersAnnotationBuilder.build()); getTypeManagementService().createOrUpdateTypeOnDisk(typeDetailsBuilder.build());
public void setSuperclass(final ClassOrInterfaceTypeDetails superclass) { setSuperclass(new ClassOrInterfaceTypeDetailsBuilder(superclass)); }
public ClassOrInterfaceTypeDetails build() { ClassOrInterfaceTypeDetails superclass = null; if (this.superclass != null) { superclass = this.superclass.build(); } return new DefaultClassOrInterfaceTypeDetails(getCustomData().build(), getDeclaredByMetadataId(), getModifier(), buildAnnotations(), getName(), getPhysicalTypeCategory(), buildConstructors(), buildFields(), buildMethods(), buildInnerTypes(), buildInitializers(), superclass, getExtendsTypes(), getImplementsTypes(), getEnumConstants(), getRegisteredImports()); }
@Override public void createInterface(final JavaType name, final LogicalPath path, final boolean permitReservedWords) { if (!permitReservedWords) { ReservedWords.verifyReservedWordsNotPresent(name); } final String declaredByMetadataId = PhysicalTypeIdentifier.createIdentifier(name, path); final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(declaredByMetadataId, Modifier.PUBLIC, name, PhysicalTypeCategory.INTERFACE); typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build()); }
String module, JavaPackage controllerPackage) { Set<ClassOrInterfaceTypeDetails> allJsonMixin = getTypeLocationService().findClassesOrInterfaceDetailsWithAnnotation( RooJavaType.ROO_JSON_MIXIN); values = new JSONMixinAnnotationValues(mixin); if (entity.equals(values.getEntity())) { new AnnotationMetadataBuilder(RooJavaType.ROO_JSON_MIXIN); mixinAnnotation.addClassAttribute(ENTITY_KEY, entity); annotations.add(mixinAnnotation); new JavaType(String.format("%s.%sJsonMixin", controllerPackage.getFullyQualifiedPackageName(), entity.getSimpleTypeName()), module); getTypeLocationService().getPhysicalTypeCanonicalPath(mixinClass, mixinPath); final String declaredByMetadataIdItem = PhysicalTypeIdentifier.createIdentifier(mixinClass, getPathResolver().getPath(resourceIdentifierItem)); ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(declaredByMetadataIdItem, Modifier.PUBLIC + Modifier.ABSTRACT, mixinClass, PhysicalTypeCategory.CLASS); cidBuilder.setAnnotations(annotations); getTypeManagementService().createOrUpdateTypeOnDisk(cidBuilder.build());
Validate.notNull(finderName, "ERROR: Finder name required to generate finder."); final String id = getTypeLocationService().getPhysicalTypeIdentifier(entity); if (id == null) { LOGGER.warning("Cannot locate source for '" + entity.getFullyQualifiedTypeName() + "'"); return; ClassOrInterfaceTypeDetails entityDetails = getTypeLocationService().getTypeDetails(entity); AnnotationMetadata entityAnnotation = entityDetails.getAnnotation(RooJavaType.ROO_JPA_ENTITY); repository.getAnnotation(RooJavaType.ROO_REPOSITORY_JPA); AnnotationMetadataBuilder repositoryAnnotationBuilder = new AnnotationMetadataBuilder(repositoryAnnotation); new AnnotationMetadataBuilder(RooJavaType.ROO_FINDER); singleFinderAnnotation.addStringAttribute("value", finderName.getSymbolName()); if (returnType.getModule() != null) { getProjectOperations().addModuleDependency(repository.getName().getModule(), returnType.getModule()); new ClassOrInterfaceTypeDetailsBuilder(repository); cidBuilder.updateTypeAnnotation(repositoryAnnotationBuilder); getTypeManagementService().createOrUpdateTypeOnDisk(cidBuilder.build());
String pathPrefixController, String viewsList) { JavaType detailController = new JavaType(String.format("%s.%s", controllerPackage.getFullyQualifiedPackageName(), controllerName), controllerPackage.getModule()); annotations.add(new AnnotationMetadataBuilder(responseType.getAnnotation())); getPathResolver().getPath(detailController.getModule(), Path.SRC_MAIN_JAVA); final String resourceIdentifierItem = getTypeLocationService().getPhysicalTypeCanonicalPath(detailController, detailControllerPathItem); final String declaredByMetadataId = PhysicalTypeIdentifier.createIdentifier(detailController, getPathResolver().getPath(resourceIdentifierItem)); ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(declaredByMetadataId, Modifier.PUBLIC, detailController, PhysicalTypeCategory.CLASS); cidBuilder.setAnnotations(annotations); getTypeManagementService().createOrUpdateTypeOnDisk(cidBuilder.build()); createLinkFactoryClass(cidBuilder.getName());
new JavaType(String.format("%s.config.jackson.DomainModelModule", getTypeLocationService() .getTopLevelPackageForModule(module)), module.getModuleName()); Validate.notNull(domainModelModule.getModule(), "ERROR: Module name is required to generate a valid JavaType"); getPathResolver().getCanonicalPath(domainModelModule.getModule(), Path.SRC_MAIN_JAVA, domainModelModule); PhysicalTypeIdentifier.createIdentifier(domainModelModule, getPathResolver().getPath(domainModelModuleIdentifier)); final ClassOrInterfaceTypeDetailsBuilder typeBuilder = new ClassOrInterfaceTypeDetailsBuilder(mid, PUBLIC, domainModelModule, PhysicalTypeCategory.CLASS); typeBuilder.addAnnotation(new AnnotationMetadataBuilder(RooJavaType.ROO_DOMAIN_MODEL_MODULE)); getTypeManagementService().createOrUpdateTypeOnDisk(typeBuilder.build());
Validate.isTrue(!JdkJavaType.isPartOfJavaLang(name.getSimpleTypeName()), "Class name '%s' is part of java.lang", name.getSimpleTypeName()); final String declaredByMetadataId = PhysicalTypeIdentifier.createIdentifier(name, path); final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(declaredByMetadataId, modifier, name, PhysicalTypeCategory.CLASS); if (!superclass.equals(OBJECT)) { final ClassOrInterfaceTypeDetails superclassClassOrInterfaceTypeDetails = typeLocationService.getTypeDetails(superclass); if (superclassClassOrInterfaceTypeDetails != null) { cidBuilder.setSuperclass(new ClassOrInterfaceTypeDetailsBuilder( superclassClassOrInterfaceTypeDetails)); cidBuilder.setExtendsTypes(extendsTypes); cidBuilder.setImplementsTypes(implementsTypes); final List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>(); annotations.add(new AnnotationMetadataBuilder(ROO_JAVA_BEAN)); annotations.add(new AnnotationMetadataBuilder(ROO_TO_STRING)); annotations.add(new AnnotationMetadataBuilder(ROO_EQUALS)); annotations.add(new AnnotationMetadataBuilder(ROO_SERIALIZABLE)); cidBuilder.setAnnotations(annotations); typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build());
new ClassOrInterfaceTypeDetailsBuilder(classDetails); detailsBuilder.addMethod(newMethod); detailsBuilder.addField(newField); classDetails = getTypeLocationService().getTypeDetails(detailsBuilder.build().getType()); detailsBuilder.addConstructor(constructor); for (AnnotationMetadata annotation : allDeclaredAnnotations) { classDetails = getTypeLocationService().getTypeDetails(detailsBuilder.build().getType()); List<AnnotationMetadata> javaDeclaredAnnotations = classDetails.getAnnotations(); boolean annotationExists = false; detailsBuilder.addAnnotation(annotation); if (!detailsBuilder.getExtendsTypes().contains(extendsType)) { detailsBuilder.addExtendsTypes(extendsType); if (!detailsBuilder.getImplementsTypes().contains(implementsType)) { detailsBuilder.addImplementsType(implementsType); detailsBuilder.addImports(allRegisteredImports); getTypeManagementService().createOrUpdateTypeOnDisk(detailsBuilder.build());
PhysicalTypeIdentifier.createIdentifier(sei, getPathResolver().getPath(seiIdentifier)); ClassOrInterfaceTypeDetailsBuilder cidBuilderSEI = new ClassOrInterfaceTypeDetailsBuilder(midSEI, Modifier.PUBLIC, sei, PhysicalTypeCategory.INTERFACE); cidBuilderSEI.addAnnotation(seiAnnotation); getTypeManagementService().createOrUpdateTypeOnDisk(cidBuilderSEI.build()); endpointClass); final String midEndpoint = PhysicalTypeIdentifier.createIdentifier(endpointClass, getPathResolver().getPath(endpointIdentifier)); ClassOrInterfaceTypeDetailsBuilder cidBuilderEndpoint = new ClassOrInterfaceTypeDetailsBuilder(midEndpoint, Modifier.PUBLIC, endpointClass, PhysicalTypeCategory.CLASS); cidBuilderEndpoint.addAnnotation(endpointAnnotation); cidBuilderEndpoint.addImplementsType(sei); getTypeManagementService().createOrUpdateTypeOnDisk(cidBuilderEndpoint.build()); cidBuilderConfig = new ClassOrInterfaceTypeDetailsBuilder(configClassDetails); cidBuilderConfig.getDeclaredTypeAnnotation(RooJavaType.ROO_WS_ENDPOINTS); if (wsEndpointsAnnotation != null) { cidBuilderConfig.addAnnotation(wsEndpointsAnnotation);
new ClassOrInterfaceTypeDetailsBuilder(declaredByMetadataId); cidBuilder.setName(name); cidBuilder.setPhysicalTypeCategory(physicalTypeCategory); cidBuilder.add(newImport.build()); cidBuilder.setModifier(JavaParserUtils.getJdkModifier(typeDeclaration.getModifiers())); JavaParserUtils .getJavaTypeNow(compilationUnitServices, candidate, typeParameterNames); cidBuilder.addExtendsTypes(javaType); final List<JavaType> extendsTypes = cidBuilder.getExtendsTypes(); cidBuilder.setSuperclass(superPtm.getMemberHoldingTypeDetails()); JavaParserUtils .getJavaTypeNow(compilationUnitServices, candidate, typeParameterNames); cidBuilder.addImplementsType(javaType); if (constants != null) { for (final EnumConstantDeclaration enumConstants : constants) { cidBuilder.addEnumConstant(new JavaSymbolName(enumConstants.getName())); cidBuilder.addAnnotation(md); cidBuilder.addField(field);
new JavaType(String.format("%sImpl", interfaceType.getFullyQualifiedTypeName()), interfaceType.getModule()); new AnnotationMetadataBuilder(ROO_SERVICE_IMPL); implAnnotationMetadata.addAttribute(new ClassAttributeValue(new JavaSymbolName("service"), interfaceType)); PhysicalTypeIdentifier.createIdentifier(implType, pathResolver.getPath(implIdentifier)); final ClassOrInterfaceTypeDetailsBuilder implTypeBuilder = new ClassOrInterfaceTypeDetailsBuilder(implMid, PUBLIC, implType, PhysicalTypeCategory.CLASS); implTypeBuilder.addAnnotation(implAnnotationMetadata.build()); implTypeBuilder.addImplementsType(interfaceType); PhysicalTypeIdentifier.createIdentifier(implTypeBuilder.build().getType(), pathResolver.getPath(implType.getModule(), Path.SRC_MAIN_JAVA)); typeManagementService.createOrUpdateTypeOnDisk(implTypeBuilder.build()); projectOperations.addModuleDependency(implType.getModule(), interfaceType.getModule()); projectOperations.addModuleDependency(implType.getModule(), repository.getName().getModule()); projectOperations.addModuleDependency(implType.getModule(), domainType.getModule());
Validate.isTrue(cid.getPhysicalTypeCategory() == PhysicalTypeCategory.CLASS, "Type %s is not a class", currentEntity.getFullyQualifiedTypeName()); Validate.isTrue(!Modifier.isAbstract(cid.getModifier()), "Type %s is abstract", currentEntity.getFullyQualifiedTypeName()); final AnnotationMetadata entityAnnotation = memberDetails.getAnnotation(ENTITY); Validate.isTrue(entityAnnotation != null, "Type %s must be a JPA entity type", currentEntity.getFullyQualifiedTypeName()); PhysicalTypeIdentifier.createIdentifier(factoryClass, path); if (metadataService.get(declaredByMetadataId) != null) { new ClassOrInterfaceTypeDetailsBuilder(declaredByMetadataId, Modifier.PUBLIC, factoryClass, PhysicalTypeCategory.CLASS); new AnnotationMetadataBuilder(RooJavaType.ROO_JPA_ENTITY_FACTORY); entityFactoryAnnotation.addClassAttribute("entity", entity); cidBuilder.addAnnotation(entityFactoryAnnotation); typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build()); currentEntityFactory = cidBuilder.getName();
new JavaType(String.format("%s.web.MainController", getProjectOperations() .getTopLevelPackage(module.getModuleName())), module.getModuleName()); getTypeLocationService().getTypeDetails(mainController); mainControllerDetails.getAnnotation(getMainControllerAnnotation()); getPathResolver().getPath(mainController.getModule(), Path.SRC_MAIN_JAVA); final String resourceIdentifier = getTypeLocationService().getPhysicalTypeCanonicalPath(mainController, controllerPath); final String declaredByMetadataId = PhysicalTypeIdentifier.createIdentifier(mainController, getPathResolver().getPath(resourceIdentifier)); annotations.add(new AnnotationMetadataBuilder(getMainControllerAnnotation())); new ClassOrInterfaceTypeDetailsBuilder(declaredByMetadataId, Modifier.PUBLIC, mainController, PhysicalTypeCategory.CLASS); cidBuilder.setAnnotations(annotations); getTypeManagementService().createOrUpdateTypeOnDisk(cidBuilder.build());
getPushInOperations().pushIn(klass.getPackage(), klass, methodName, false); new NestedAnnotationAttributeValue(new JavaSymbolName("value"), getRooSecurityAuthorizationsAnnotation(method.getMethodName().getSymbolName(), lstParamTypes, roles, usernames).build()); rooSecurityAuthorizationsToAdd.add(newFilter); ClassOrInterfaceTypeDetails serviceDetails = getTypeLocationService().getTypeDetails(klass); ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(serviceDetails); serviceDetails.getAnnotation(RooJavaType.ROO_SECURITY_AUTHORIZATIONS); AnnotationMetadataBuilder annotationAuthorizationsMetadataBuilder; new AnnotationMetadataBuilder(annotationAuthorizations); cidBuilder.removeAnnotation(RooJavaType.ROO_SECURITY_AUTHORIZATIONS); new AnnotationMetadataBuilder(RooJavaType.ROO_SECURITY_AUTHORIZATIONS); cidBuilder.addAnnotation(annotationAuthorizationsMetadataBuilder); getTypeManagementService().createOrUpdateTypeOnDisk(cidBuilder.build()); getProjectOperations().addDependency(klass.getModule(), SPRING_SECURITY_CORE, false);
Validate.notNull(interfaceType.getModule(), "JavaType %s does not have a module", domainType); pathResolver.getCanonicalPath(interfaceType.getModule(), Path.SRC_MAIN_JAVA, interfaceType); if (fileManager.exists(interfaceIdentifier)) { return; // Type already exists - nothing to do ClassOrInterfaceTypeDetails entityDetails = typeLocationService.getTypeDetails(domainType); Validate.notNull(entityDetails.getAnnotation(RooJavaType.ROO_JPA_ENTITY), "ERROR: Provided entity should be annotated with @RooJpaEntity"); PhysicalTypeIdentifier.createIdentifier(interfaceType, pathResolver.getPath(interfaceIdentifier)); final ClassOrInterfaceTypeDetailsBuilder interfaceTypeBuilder = new ClassOrInterfaceTypeDetailsBuilder(interfaceMid, PUBLIC, interfaceType, PhysicalTypeCategory.INTERFACE); JavaType.wrapperOf(SpringletsJavaType.SPRINGLETS_ENTITY_RESOLVER, domainType, idType); interfaceTypeBuilder.addExtendsTypes(entityResolver); JavaType.wrapperOf(SpringletsJavaType.SPRINGLETS_VALIDATOR_SERVICE, domainType); interfaceTypeBuilder.addExtendsTypes(validatorServiceEntity); interfaceTypeBuilder.addAnnotation(interfaceAnnotationMetadata.build()); typeManagementService.createOrUpdateTypeOnDisk(interfaceTypeBuilder.build());
Validate.notNull(name, "Name of the new data on demand provider is required"); final LogicalPath path = LogicalPath.getInstance(Path.SRC_TEST_JAVA, name.getModule()); Validate.notNull(path, "Location of the new data on demand provider is required"); projectOperations.addDependency(name.getModule(), VALIDATION_API_DEPENDENCY); final String declaredByMetadataId = PhysicalTypeIdentifier.createIdentifier(name, path); if (metadataService.get(declaredByMetadataId) != null) { return new ClassOrInterfaceTypeDetailsBuilder(declaredByMetadataId).getName(); new ArrayList<AnnotationAttributeValue<?>>(); dodConfig.add(new ClassAttributeValue(new JavaSymbolName("entity"), entity)); annotations.add(new AnnotationMetadataBuilder(RooJavaType.ROO_JPA_DATA_ON_DEMAND, dodConfig)); new ClassOrInterfaceTypeDetailsBuilder(declaredByMetadataId, Modifier.PUBLIC, name, PhysicalTypeCategory.CLASS); cidBuilder.setAnnotations(annotations); final ClassOrInterfaceTypeDetails dodClassCid = cidBuilder.build(); typeManagementService.createOrUpdateTypeOnDisk(dodClassCid); return cid.getName();