/** * Returns the {@link JavaType} representing the physical type of this ITD governor. * * @return the {@link JavaType} for the governor physical type. */ public JavaType getGovernorType() { return this.governorPhysicalTypeMetadata.getType(); }
public FieldMetadata getIdentifier(final PhysicalTypeMetadata governorPhysicalTypeMetadata) { List<FieldMetadata> identifierFields = getPersistenceMemberLocator().getIdentifierFields(governorPhysicalTypeMetadata.getType()); FieldMetadata identifierField = null; if (!identifierFields.isEmpty()) { identifierField = identifierFields.get(0); } return identifierField; }
@Override protected ItdTypeDetailsProvidingMetadataItem getMetadata( final String metadataIdentificationString, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata, final String itdFilename) { // Obtain the fields that are annotated with Audit annotations List<FieldMetadata> auditFields = new ArrayList<FieldMetadata>(); JavaType annotatedEntity = governorPhysicalTypeMetadata.getType(); ClassOrInterfaceTypeDetails entityDetails = getTypeLocationService().getTypeDetails(annotatedEntity); auditFields.addAll(entityDetails.getFieldsWithAnnotation(SpringJavaType.CREATED_DATE)); auditFields.addAll(entityDetails.getFieldsWithAnnotation(SpringJavaType.LAST_MODIFIED_DATE)); auditFields.addAll(entityDetails.getFieldsWithAnnotation(SpringJavaType.CREATED_BY)); auditFields.addAll(entityDetails.getFieldsWithAnnotation(SpringJavaType.LAST_MODIFIED_BY)); return new JpaAuditMetadata(metadataIdentificationString, aspectName, governorPhysicalTypeMetadata, auditFields); }
private void registerDependencyModulesOfFinder( final PhysicalTypeMetadata governorPhysicalTypeMetadata, MethodMetadata finder) { // Add dependencies between modules List<JavaType> types = new ArrayList<JavaType>(); types.add(finder.getReturnType()); types.addAll(finder.getReturnType().getParameters()); for (AnnotatedJavaType parameter : finder.getParameterTypes()) { types.add(parameter.getJavaType()); types.addAll(parameter.getJavaType().getParameters()); } for (JavaType parameter : types) { getTypeLocationService().addModuleDependency( governorPhysicalTypeMetadata.getType().getModule(), parameter); } }
@Override protected ItdTypeDetailsProvidingMetadataItem getMetadata( final String metadataIdentificationString, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata, final String itdFilename) { // Get application main class Set<JavaType> applicationTypes = getTypeLocationService().findTypesWithAnnotation(SpringJavaType.SPRING_BOOT_APPLICATION); String repositoryConfigurationModuleName = governorPhysicalTypeMetadata.getType().getModule(); JavaType applicationMainType = null; for (JavaType applicationType : applicationTypes) { if (applicationType.getModule().equals(repositoryConfigurationModuleName)) { applicationMainType = applicationType; } } Validate.notNull(applicationMainType, "Unable to find a main application class on module %s", repositoryConfigurationModuleName); // Check if security is installed in module boolean isSpringletsSecurityEnabled = getProjectOperations() .isFeatureInstalled(applicationMainType.getModule(), "SPRINGLETS_JPA"); return new RepositoryJpaConfigurationMetadata(metadataIdentificationString, aspectName, governorPhysicalTypeMetadata, applicationMainType, isSpringletsSecurityEnabled); }
/** * Builds constructor with EntityManager argument. * * @return ConstructorMetadataBuilder for adding constructor to ITD */ private ConstructorMetadataBuilder getConstructorWithEntityManager() { ConstructorMetadataBuilder constructorBuilder = new ConstructorMetadataBuilder(getId()); InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); constructorBuilder.addParameter(ENTITY_MANAGER_VAR, JpaJavaType.ENTITY_MANAGER); // this(entityManager, 10); bodyBuilder.appendFormalLine(String.format("this(%1$s, 10);", ENTITY_MANAGER_VAR)); constructorBuilder.setModifier(Modifier.PUBLIC); constructorBuilder.setBodyBuilder(bodyBuilder); CommentStructure comment = new CommentStructure(); List<String> paramsInfo = new ArrayList<String>(); paramsInfo.add(ENTITY_MANAGER_VAR + " to persist entities"); JavadocComment javadocComment = new JavadocComment(String.format("Creates a new {@link %s}.", this.governorPhysicalTypeMetadata.getType().getSimpleTypeName()), paramsInfo, null, null); comment.addComment(javadocComment, CommentLocation.BEGINNING); constructorBuilder.setCommentStructure(comment); return constructorBuilder; }
/** * Constructor * * @param identifier * @param aspectName * @param governorPhysicalTypeMetadata */ public EntityProjectionMetadata(final String identifier, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata, final EntityProjectionAnnotationValues annotationValues, final List<FieldMetadata> fields) { super(identifier, aspectName, governorPhysicalTypeMetadata); Validate .isTrue( isValid(identifier), "Metadata identification string '%s' does not appear to be a valid physical type identifier", identifier); this.fields = fields; this.annotationValues = annotationValues; this.type = governorPhysicalTypeMetadata.getType(); ConstructorMetadataBuilder constructorMetadata = getConstructor(); if (!constructorMetadata.getParameterTypes().isEmpty()) { ensureGovernorHasConstructor(constructorMetadata); } // ROO-3868: New entity visualization support using a new format annotation ensureGovernorIsAnnotated(new AnnotationMetadataBuilder(getEntityFormatAnnotation())); // Build ITD itdTypeDetails = builder.build(); }
this.target = governorPhysicalTypeMetadata.getType(); this.annotationValues = annotationValues; this.declaredFields = declaredFields;
/** * Constructor * * @param identifier * @param aspectName * @param governorPhysicalTypeMetadata */ public DtoMetadata(final String identifier, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata, final DtoAnnotationValues annotationValues, List<FieldMetadata> fields) { super(identifier, aspectName, governorPhysicalTypeMetadata); Validate .isTrue( isValid(identifier), "Metadata identification string '%s' does not appear to be a valid physical type identifier", identifier); this.annotationValues = annotationValues; this.fields = fields; this.type = governorPhysicalTypeMetadata.getType(); if (annotationValues.getImmutable()) { ConstructorMetadataBuilder constructorMetadata = getConstructor(); if (!constructorMetadata.getParameterTypes().isEmpty()) { ensureGovernorHasConstructor(constructorMetadata); } } // ROO-3868: New entity visualization support using a new format annotation ensureGovernorIsAnnotated(new AnnotationMetadataBuilder(getEntityFormatAnnotation())); // Build ITD itdTypeDetails = builder.build(); }
/** * Builds constructor with EntityManager and size arguments. * * @return {@link ConstructorMetadataBuilder} for adding constructor to ITD */ private ConstructorMetadataBuilder getConstructorWithEntityManagerAndSize() { ConstructorMetadataBuilder constructorBuilder = new ConstructorMetadataBuilder(getId()); InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); constructorBuilder.addParameter(ENTITY_MANAGER_VAR, JpaJavaType.ENTITY_MANAGER); constructorBuilder.addParameter(SIZE_VAR, JavaType.INT_PRIMITIVE); bodyBuilder.appendFormalLine(String.format("%1$s(%2$s);", getMutatorMethod(getEntityManagerField().build()).getMethodName(), ENTITY_MANAGER_VAR)); bodyBuilder.appendFormalLine(String.format("%1$s(%2$s);", getMutatorMethod(getSizeField()) .getMethodName(), SIZE_VAR)); constructorBuilder.setModifier(Modifier.PUBLIC); constructorBuilder.setBodyBuilder(bodyBuilder); CommentStructure comment = new CommentStructure(); List<String> paramsInfo = new ArrayList<String>(); paramsInfo.add(ENTITY_MANAGER_VAR + " to persist entities"); paramsInfo.add(SIZE_VAR + " the number of entities to create and persist initially."); JavadocComment javadocComment = new JavadocComment(String.format("Creates a new {@link %s}.", this.governorPhysicalTypeMetadata.getType().getSimpleTypeName()), paramsInfo, null, null); comment.addComment(javadocComment, CommentLocation.BEGINNING); constructorBuilder.setCommentStructure(comment); return constructorBuilder; }
final JavaType mixinType = governorPhysicalTypeMetadata.getType();
JavaType annotatedService = governorPhysicalTypeMetadata.getType();
JavaType annotatedEntity = governorPhysicalTypeMetadata.getType();
final JavaType target = governorPhysicalTypeMetadata.getType();
JavaType annotatedService = governorPhysicalTypeMetadata.getType();
public FieldMetadata getLoggerField() { InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); bodyBuilder.append(getNameOfJavaType(LOGGER_FACTORY_JAVA_TYPE)); bodyBuilder.append(".getLogger("); bodyBuilder.append(governorPhysicalTypeMetadata.getType().getSimpleTypeName()); bodyBuilder.append(".class)"); final String initializer = bodyBuilder.getOutput(); FieldMetadataBuilder field = new FieldMetadataBuilder(getId(), Modifier.PRIVATE | Modifier.STATIC | Modifier.FINAL, new JavaSymbolName("LOG"), LOGGER_JAVA_TYPE, initializer); return field.build(); }
super(identifier, aspectName, governorPhysicalTypeMetadata); this.governor = governorPhysicalTypeMetadata.getType(); this.endpointsAndSeis = endpointsAndSeis; this.endpointsAndServices = endpointsAndServices;
+ "the initial list of the created entities,".concat(IOUtils.LINE_SEPARATOR) .concat("with an index greater than {@link %s#getSize()} - 1."), this.entity .getSimpleTypeName(), this.governorPhysicalTypeMetadata.getType() .getSimpleTypeName()), null, String.format( "%1$s the generated transient {@link %1$s}", this.entity.getSimpleTypeName()), null);
super(identifier, aspectName, governorPhysicalTypeMetadata); this.governor = governorPhysicalTypeMetadata.getType(); this.endPoints = endPoints; this.profile = profile;
final JavaType deserializerType = governorPhysicalTypeMetadata.getType();