Package org.springframework.roo.model

Examples of org.springframework.roo.model.JavaSymbolName


        itdTypeDetails = builder.build();
    }

    private MethodMetadataBuilder getFromJsonArrayMethod() {
        // Compute the relevant method name
        final JavaSymbolName methodName = getFromJsonArrayMethodName();
        if (methodName == null) {
            return null;
        }

        final JavaType parameterType = JavaType.STRING;
        if (governorHasMethod(methodName, parameterType)) {
            return null;
        }

        final String list = LIST.getNameIncludingTypeParameters(false,
                builder.getImportRegistrationResolver());
        final String arrayList = ARRAY_LIST.getNameIncludingTypeParameters(
                false, builder.getImportRegistrationResolver());
        final String bean = destination.getSimpleTypeName();

        final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
        final String deserializer = JSON_DESERIALIZER
                .getNameIncludingTypeParameters(false,
                        builder.getImportRegistrationResolver());
        bodyBuilder.appendFormalLine("return new " + deserializer + "<" + list
                + "<" + bean + ">>()");
        if (annotationValues.isIso8601Dates()) {
            bodyBuilder
                    .appendFormalLine(".use(java.util.Date.class, "
                            + "new flexjson.transformer.DateTransformer(\"yyyy-MM-dd\"))");
        }
        bodyBuilder.appendFormalLine(".use(\"values\", " + bean
                + ".class).deserialize(json);");

        final List<JavaSymbolName> parameterNames = Arrays
                .asList(new JavaSymbolName("json"));

        final JavaType collection = new JavaType(
                COLLECTION.getFullyQualifiedTypeName(), 0, DataType.TYPE, null,
                Arrays.asList(destination));
View Full Code Here


        final String methodLabel = annotationValues.getFromJsonArrayMethod();
        if (StringUtils.isBlank(methodLabel)) {
            return null;
        }

        return new JavaSymbolName(methodLabel.replace("<TypeNamePlural>",
                typeNamePlural));
    }
View Full Code Here

        return new JavaSymbolName(methodLabel.replace("<TypeNamePlural>",
                typeNamePlural));
    }

    private MethodMetadataBuilder getFromJsonMethod() {
        final JavaSymbolName methodName = getFromJsonMethodName();
        if (methodName == null) {
            return null;
        }

        final JavaType parameterType = JavaType.STRING;
        if (governorHasMethod(methodName, parameterType)) {
            return null;
        }

        final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
        final String deserializer = JSON_DESERIALIZER
                .getNameIncludingTypeParameters(false,
                        builder.getImportRegistrationResolver());
        bodyBuilder.appendFormalLine("return new " + deserializer + "<"
                        + destination.getSimpleTypeName()
                        + ">()");
        if (annotationValues.isIso8601Dates()) {
            bodyBuilder
                    .appendFormalLine(".use(java.util.Date.class, "
                            + "new flexjson.transformer.DateTransformer(\"yyyy-MM-dd\"))");
        }
        bodyBuilder.appendFormalLine(".use(null, "
                + destination.getSimpleTypeName()
                + ".class).deserialize(json);");

        final List<JavaSymbolName> parameterNames = Arrays
                .asList(new JavaSymbolName("json"));

        final MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(
                getId(), Modifier.PUBLIC | Modifier.STATIC, methodName,
                destination,
                AnnotatedJavaType.convertFromJavaTypes(parameterType),
View Full Code Here

     * @return the method, or null if not found
     */
    public static MethodMetadata getMethod(final MemberDetails memberDetails,
            final String methodName) {
        Validate.notNull(methodName, "Method name required");
        return memberDetails.getMethod(new JavaSymbolName(methodName));
    }
View Full Code Here

     */
    public static MethodMetadata getMethod(
            final MemberHoldingTypeDetails memberHoldingTypeDetails,
            final String methodName) {
        return memberHoldingTypeDetails
                .getMethod(new JavaSymbolName(methodName));
    }
View Full Code Here

        if (StringUtils.isBlank(methodLabel)) {
            return null;
        }

        // Compute the relevant method name
        return new JavaSymbolName(methodLabel.replace("<TypeName>",
                destination.getSimpleTypeName()));
    }
View Full Code Here

        if (StringUtils.isBlank(toStringMethod)) {
            return null;
        }

        // Compute the relevant toString method name
        final JavaSymbolName methodName = new JavaSymbolName(toStringMethod);

        // See if the type itself declared the method
        if (governorHasMethod(methodName)) {
            return null;
        }
View Full Code Here

        List<JavaType> hasPermissionParameterTypes = new ArrayList<JavaType>();
        hasPermissionParameterTypes.add(AUTHENTICATION);
        hasPermissionParameterTypes.add(JavaType.OBJECT);
        hasPermissionParameterTypes.add(JavaType.OBJECT);

        JavaSymbolName hasPermissionMethodName = new JavaSymbolName("hasPermission");
        if (!governorDetails.isMethodDeclaredByAnother(hasPermissionMethodName,
                hasPermissionParameterTypes, getId())) {
         
          List<JavaSymbolName> hasPermissionParameterNames = new ArrayList<JavaSymbolName>();
            hasPermissionParameterNames.add(new JavaSymbolName("authentication"));
            hasPermissionParameterNames.add(new JavaSymbolName("targetObject"));
            hasPermissionParameterNames.add(new JavaSymbolName("permission"));
           
            final InvocableMemberBodyBuilder hasPermissionBodyBuilder = new InvocableMemberBodyBuilder();
           
            hasPermissionBodyBuilder.append("\n\t\treturn checkManagedPermissions(authentication, targetObject, permission);");

            MethodMetadataBuilder hasPermissionMethodMetadataBuilder = new MethodMetadataBuilder(
                    getId(), PUBLIC, hasPermissionMethodName, JavaType.BOOLEAN_PRIMITIVE,
                    AnnotatedJavaType
                            .convertFromJavaTypes(hasPermissionParameterTypes),
                    hasPermissionParameterNames, hasPermissionBodyBuilder);

            builder.addMethod(hasPermissionMethodMetadataBuilder.build());
        }
       
        //Creates method hasPermission(Authentication authentication, Serializable targetId, String targetType, Object permission)
        hasPermissionParameterTypes = new ArrayList<JavaType>();
        hasPermissionParameterTypes.add(AUTHENTICATION);
        hasPermissionParameterTypes.add(JavaType.SERIALIZABLE);
        hasPermissionParameterTypes.add(JavaType.STRING);
        hasPermissionParameterTypes.add(JavaType.OBJECT);

        if (!governorDetails.isMethodDeclaredByAnother(hasPermissionMethodName,
                hasPermissionParameterTypes, getId())) {
            final InvocableMemberBodyBuilder hasPermissionBodyBuilder2 = new InvocableMemberBodyBuilder();
            hasPermissionBodyBuilder2.append(String.format("\n\t\treturn %s;\n",annotationValues.getDefaultReturnValue()));

            List<JavaSymbolName> hasPermissionParameterNames2 = new ArrayList<JavaSymbolName>();
            hasPermissionParameterNames2.add(new JavaSymbolName(
                    "authentication"));
            hasPermissionParameterNames2.add(new JavaSymbolName("targetId"));
            hasPermissionParameterNames2.add(new JavaSymbolName("targetType"));
            hasPermissionParameterNames2.add(new JavaSymbolName("permission"));

            MethodMetadataBuilder hasPermissionMethodMetadataBuilder2 = new MethodMetadataBuilder(
                    getId(),
                    PUBLIC,
                    new JavaSymbolName("hasPermission"),
                    JavaType.BOOLEAN_PRIMITIVE,
                    AnnotatedJavaType
                            .convertFromJavaTypes(hasPermissionParameterTypes),
                    hasPermissionParameterNames2, hasPermissionBodyBuilder2);

            builder.addMethod(hasPermissionMethodMetadataBuilder2.build());
        }
       
        List<JavaType> checkManagedPermissionsParameterTypes = new ArrayList<JavaType>();
        checkManagedPermissionsParameterTypes.add(AUTHENTICATION);
        checkManagedPermissionsParameterTypes.add(JavaType.OBJECT);
        checkManagedPermissionsParameterTypes.add(JavaType.OBJECT);

        JavaSymbolName checkManagedPermissionsMethodName = new JavaSymbolName("checkManagedPermissions");
       
        if (!governorDetails.isMethodDeclaredByAnother(checkManagedPermissionsMethodName,
            checkManagedPermissionsParameterTypes, getId())) {
         
          List<JavaSymbolName> checkManagedPermissionsParameterNames = new ArrayList<JavaSymbolName>();
          checkManagedPermissionsParameterNames
                    .add(new JavaSymbolName("authentication"));
          checkManagedPermissionsParameterNames.add(new JavaSymbolName("targetObject"));
          checkManagedPermissionsParameterNames.add(new JavaSymbolName("permission"));
           
            final InvocableMemberBodyBuilder checkManagedPermissionsBodyBuilder = new InvocableMemberBodyBuilder();
            boolean firstPass = true;
            for (Entry<JavaType, String> entrySet : domainTypeToPlurals.entrySet()) {
              for (Permission permission : Permission.values()){
              String permissionName = permission.getName(entrySet.getKey(), entrySet.getValue());
            if (permissionName == null) {
              continue;
            }
                checkManagedPermissionsBodyBuilder.append(String.format("\n\t\t%sif(permission.equals(\"%s\")){",firstPass ? "" : "else ", permissionName));
                checkManagedPermissionsBodyBuilder.append(String.format("\n\t\t\treturn %s(authentication, (%s)targetObject);", permissionName, entrySet.getKey().getFullyQualifiedTypeName()));
                checkManagedPermissionsBodyBuilder.append("\n\t\t}");
              }
              firstPass = false;
            }
            checkManagedPermissionsBodyBuilder.append(String.format("\n\t\treturn %s;\n",annotationValues.getDefaultReturnValue()));

            MethodMetadataBuilder hasPermissionMethodMetadataBuilder = new MethodMetadataBuilder(
                    getId(), PUBLIC, checkManagedPermissionsMethodName, JavaType.BOOLEAN_PRIMITIVE,
                    AnnotatedJavaType
                            .convertFromJavaTypes(checkManagedPermissionsParameterTypes),
                            checkManagedPermissionsParameterNames, checkManagedPermissionsBodyBuilder);

            builder.addMethod(hasPermissionMethodMetadataBuilder.build());
           
        }
       
        for (Entry<JavaType, String> entrySet : domainTypeToPlurals.entrySet()) {
          for (Permission permission : Permission.values()){
          String permissionName = permission.getName(entrySet.getKey(), entrySet.getValue());
        if (permissionName == null) {
          continue;
        }
            JavaSymbolName isAllowedMethodName = new JavaSymbolName(permissionName);
            List<JavaType> isAllowedParameterTypes = new ArrayList<JavaType>();
            isAllowedParameterTypes.add(AUTHENTICATION);
            isAllowedParameterTypes.add(entrySet.getKey());
            if (!governorDetails.isMethodDeclaredByAnother(isAllowedMethodName, isAllowedParameterTypes, getId())) {
              List<JavaSymbolName> isAllowedParameterNames = new ArrayList<JavaSymbolName>();
              isAllowedParameterNames.add(new JavaSymbolName("authentication"));
              isAllowedParameterNames.add(JavaSymbolName.getReservedWordSafeName(entrySet.getKey()));
                 
                  final InvocableMemberBodyBuilder isAllowedBodyBuilder = new InvocableMemberBodyBuilder();
                  isAllowedBodyBuilder.append(String.format("\n\t\treturn %s;\n",annotationValues.getDefaultReturnValue()));
 
View Full Code Here

        }

        // Unqualified name detected, so check if it's in the type parameter
        // list
        if (typeParameters != null
                && typeParameters.contains(new JavaSymbolName(nameToFind
                        .getName()))) {
            return new JavaType(nameToFind.getName(), 0, DataType.VARIABLE,
                    null, null);
        }
       
View Full Code Here

            final List<TypeParameter> typeParameters = clazz
                    .getTypeParameters();
            if (typeParameters != null) {
                final Set<JavaSymbolName> locatedTypeParameters = new HashSet<JavaSymbolName>();
                for (final TypeParameter candidate : typeParameters) {
                    final JavaSymbolName currentTypeParam = new JavaSymbolName(
                            candidate.getName());
                    locatedTypeParameters.add(currentTypeParam);
                    JavaType javaType = null;
                    if (candidate.getTypeBound() == null) {
                        javaType = new JavaType(
View Full Code Here

TOP

Related Classes of org.springframework.roo.model.JavaSymbolName

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.