Search in sources :

Example 6 with ClassAccessor

use of com.manydesigns.elements.reflection.ClassAccessor in project Portofino by ManyDesigns.

the class JodaTimeFieldTest method setupFields.

private void setupFields(Mode mode) throws NoSuchFieldException {
    ClassAccessor classAccessor = JavaClassAccessor.getClassAccessor(this.getClass());
    PropertyAccessor myPropertyAccessor = classAccessor.getProperty("date");
    dateField = new JodaTimeField(myPropertyAccessor, mode, null);
}
Also used : PropertyAccessor(com.manydesigns.elements.reflection.PropertyAccessor) JavaClassAccessor(com.manydesigns.elements.reflection.JavaClassAccessor) ClassAccessor(com.manydesigns.elements.reflection.ClassAccessor)

Example 7 with ClassAccessor

use of com.manydesigns.elements.reflection.ClassAccessor in project Portofino by ManyDesigns.

the class AbstractResourceAction method getConfiguration.

/**
 * Returns the configuration of this action, filtered using permissions.
 * @return the configuration.
 */
@io.swagger.v3.oas.annotations.Operation(operationId = "com.manydesigns.portofino.resourceactions.AbstractResourceAction#getConfiguration", description = "Returns the configuration of this action. " + "The actual type of the configuration object depends on the action class.")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "The configuration object.") })
@Path(":configuration")
@GET
@Produces(MimeTypes.APPLICATION_JSON_UTF8)
public Object getConfiguration() {
    Object configuration = actionInstance.getConfiguration();
    if (getConfigurationClass() == null) {
        return configuration;
    }
    ClassAccessor classAccessor = getConfigurationClassAccessor();
    ClassAccessor filteredClassAccessor = filterAccordingToPermissions(classAccessor);
    ResourceActionConfiguration filtered = (ResourceActionConfiguration) classAccessor.newInstance();
    for (PropertyAccessor propertyAccessor : filteredClassAccessor.getProperties()) {
        if (propertyAccessor.isWritable()) {
            propertyAccessor.set(filtered, propertyAccessor.get(configuration));
        }
    }
    filtered.init();
    return filtered;
}
Also used : PropertyAccessor(com.manydesigns.elements.reflection.PropertyAccessor) ClassAccessor(com.manydesigns.elements.reflection.ClassAccessor) JavaClassAccessor(com.manydesigns.elements.reflection.JavaClassAccessor) FilteredClassAccessor(com.manydesigns.elements.reflection.FilteredClassAccessor) FileObject(org.apache.commons.vfs2.FileObject) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 8 with ClassAccessor

use of com.manydesigns.elements.reflection.ClassAccessor in project Portofino by ManyDesigns.

the class SelectFieldTest method setupSelectFields.

private void setupSelectFields(Mode mode) {
    ClassAccessor classAccessor = JavaClassAccessor.getClassAccessor(this.getClass());
    PropertyAccessor myPropertyAccessor = null;
    try {
        myPropertyAccessor = classAccessor.getProperty("myText");
    } catch (NoSuchFieldException e) {
        fail(e.getMessage(), e);
    }
    // impostiamo selectField1
    selectField = new SelectField(myPropertyAccessor, mode, null);
    selectField.setSelectionModel(selectionModel);
    // impostiamo selectField2
    selectField2 = new SelectField(myPropertyAccessor, mode, null);
    selectField2.setSelectionModel(selectionModel2);
    // impostiamo selectField3
    selectField3 = new SelectField(myPropertyAccessor, mode, null);
    selectField3.setSelectionModel(selectionModel3);
}
Also used : PropertyAccessor(com.manydesigns.elements.reflection.PropertyAccessor) JavaClassAccessor(com.manydesigns.elements.reflection.JavaClassAccessor) ClassAccessor(com.manydesigns.elements.reflection.ClassAccessor)

Example 9 with ClassAccessor

use of com.manydesigns.elements.reflection.ClassAccessor in project Portofino by ManyDesigns.

the class DefaultLoginAction method describeNewUserClassAccessor.

@Path("user/classAccessor")
@GET
@Produces(MimeTypes.APPLICATION_JSON_UTF8)
@Operation(summary = "The class accessor that describes the registration of a new user")
public String describeNewUserClassAccessor() {
    ClassAccessor classAccessor = getNewUserClassAccessor();
    JSONStringer jsonStringer = new JSONStringer();
    ReflectionUtil.classAccessorToJson(classAccessor, jsonStringer);
    return jsonStringer.toString();
}
Also used : ClassAccessor(com.manydesigns.elements.reflection.ClassAccessor) JSONStringer(org.json.JSONStringer) Operation(io.swagger.v3.oas.annotations.Operation)

Example 10 with ClassAccessor

use of com.manydesigns.elements.reflection.ClassAccessor in project Portofino by ManyDesigns.

the class AbstractResourceAction method getConfigurationAccessor.

@io.swagger.v3.oas.annotations.Operation(operationId = "com.manydesigns.portofino.resourceactions.AbstractResourceAction#getConfigurationAccessor", description = "A ClassAccessor that describes the configuration of this action.")
@GET
@Path(":configuration/classAccessor")
@Produces(MimeTypes.APPLICATION_JSON_UTF8)
public String getConfigurationAccessor() {
    ClassAccessor classAccessor = getConfigurationClassAccessor();
    if (classAccessor == null) {
        return null;
    }
    JSONStringer jsonStringer = new JSONStringer();
    ReflectionUtil.classAccessorToJson(classAccessor, jsonStringer);
    return jsonStringer.toString();
}
Also used : ClassAccessor(com.manydesigns.elements.reflection.ClassAccessor) JavaClassAccessor(com.manydesigns.elements.reflection.JavaClassAccessor) FilteredClassAccessor(com.manydesigns.elements.reflection.FilteredClassAccessor) JSONStringer(org.json.JSONStringer)

Aggregations

ClassAccessor (com.manydesigns.elements.reflection.ClassAccessor)18 JavaClassAccessor (com.manydesigns.elements.reflection.JavaClassAccessor)14 PropertyAccessor (com.manydesigns.elements.reflection.PropertyAccessor)13 FilteredClassAccessor (com.manydesigns.elements.reflection.FilteredClassAccessor)2 BigDecimal (java.math.BigDecimal)2 FileObject (org.apache.commons.vfs2.FileObject)2 Session (org.hibernate.Session)2 JSONStringer (org.json.JSONStringer)2 FileBlob (com.manydesigns.elements.annotations.FileBlob)1 Blob (com.manydesigns.elements.blobs.Blob)1 HierarchicalBlobManager (com.manydesigns.elements.blobs.HierarchicalBlobManager)1 AbstractBlobField (com.manydesigns.elements.fields.AbstractBlobField)1 Field (com.manydesigns.elements.fields.Field)1 FileBlobField (com.manydesigns.elements.fields.FileBlobField)1 DateSearchField (com.manydesigns.elements.fields.search.DateSearchField)1 MutableHttpServletRequest (com.manydesigns.elements.servlet.MutableHttpServletRequest)1 ActionDescriptor (com.manydesigns.portofino.actions.ActionDescriptor)1 Annotation (com.manydesigns.portofino.model.Annotation)1 Model (com.manydesigns.portofino.model.Model)1 Property (com.manydesigns.portofino.model.Property)1