TheOpenCloudEngine / uEngine5-base

uEngine5 BPMS that totally re-written in Microservices architecture. uEngine5 can act as not only a conventional Workflow or BPMS but also as a REST api orchestrator or a BPaaS (Business process as a service) of members of OCE's MSA components.
MIT License
10 stars 13 forks source link

Class Designer #7

Open jinyoung opened 6 years ago

jinyoung commented 6 years ago

Level1: just class definition that is just a group of member attribute declarations. An attribute may be complex type which type is link to other class definition or itself (recursive data structure) and it can be multiple (array) type of it.

user interface may be like this: datamodellocked

By the class model information, metaworks4 will generate the Default Work-item-handler for UI-unspecified User-tasks which only has its input/output process data.

Level2: Incorporating an UML diagraming tool to declare more complex class models, which is a step toward Model driven development.

jinyoung commented 6 years ago

Class Repository Design:

Current candidate referencing implementation for class management, class definition management:

package org.metaworks.multitenancy;

public class DefaultMetadataService implements MetadataService {

    ResourceManager resourceManager;
        public ResourceManager getResourceManager() {
            return resourceManager;
        }
        public void setResourceManager(ResourceManager resourceManager) {
            this.resourceManager = resourceManager;
        }

...
    @Override
    public ClassDefinition getClassDefinition(Class clazz, String tenantId) throws Exception {

        String className = clazz.getName();

        //load class definition in the original form (java) first
        ClassDefinition classDefinition = (new ClassDefinition());
        List<Attribute> attributeList = new ArrayList<Attribute>();
        {
            WebObjectType webObjectType = MetaworksRemoteService.getInstance().getMetaworksType(className);

            classDefinition.setFieldDescriptors(new Attribute[webObjectType.getFieldDescriptors().length]);

            int i = 0;
            for (WebFieldDescriptor fieldDescriptor : webObjectType.getFieldDescriptors()) {

                Attribute attribute = new Attribute();
                org.springframework.beans.BeanUtils.copyProperties(fieldDescriptor, attribute);
                //attribute.setAttributes(null); //TODO: this occurs some Serialization error for Map<String, Object> for boolean value

                classDefinition.getFieldDescriptors()[i] = attribute;

                i++;

                if(attribute.getAttributes()!=null)
                    attribute.getAttributes().remove("extended");

                attributeList.add(attribute);
            }

            classDefinition.setServiceMethodContexts(webObjectType.getServiceMethodContexts());
            classDefinition.setName(clazz.getName());
            classDefinition.setDisplayName(webObjectType.getDisplayName());
            classDefinition.setKeyFieldDescriptor(webObjectType.getKeyFieldDescriptor());

        }

        IResource resource = new DefaultResource("clsDef_" + tenantId + "_" + className);

        try {
            ClassDefinition overriderClassDefinition = (ClassDefinition) getResourceManager().getObject(resource);

            if(overriderClassDefinition.getFieldDescriptors()!=null)
                for(Attribute attribute : overriderClassDefinition.getFieldDescriptors()){
                    if(!attributeList.contains(attribute)){
                        attribute.setAttributes(new HashMap<String, Object>());
                        attribute.getAttributes().put("extended", "true");
                        attributeList.add(attribute);
                        if(attribute.getDisplayName()==null || attribute.getDisplayName().trim().length()==0)
                            attribute.setDisplayName(attribute.getName());
                    }else{

                    }
                }

            Attribute[] attributes = new Attribute[attributeList.size()];
            attributeList.toArray(attributes);
            classDefinition.setFieldDescriptors(attributes);

        }catch (FileNotFoundException fne){

        }catch (NullPointerException npe){

        }

        return classDefinition;
    }

    @Override
    public void setClassDefinition(ClassDefinition classDefinition, String tenantId) throws Exception {
        String className = classDefinition.getName();

        IResource resource = new DefaultResource("clsDef_" + tenantId + "_" + className);

        getResourceManager().save(resource, classDefinition);
    }

}

This loads and saves class definition in the format of serialized xml and store into a file storage (which is conforms to uEngine resource management framework (URMF))

For the uEngine5's model strage, described below:

codi
  +- com
        +- insurance
               +- Invoice.class
               +- Underwriting.process

Each model elements are designated by its extension file name, 'class' is Class definition, 'process' is a Process definition in serialized in XStream.

Candidate Approaches are:

  1. Use the DefinitionService for the common resource manager to load / save the ClassDefinition too. Pros? thinking...
  2. Use the MetadataService for alternative of DefinitionService. Pros is it covers multi-tenancy scenarios inherently.