All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.zeebe.model.bpmn.impl.instance.LaneImpl Maven / Gradle / Ivy

/*
 * Copyright © 2017 camunda services GmbH ([email protected])
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.zeebe.model.bpmn.impl.instance;

import static io.zeebe.model.bpmn.impl.BpmnModelConstants.BPMN20_NS;
import static io.zeebe.model.bpmn.impl.BpmnModelConstants.BPMN_ATTRIBUTE_NAME;
import static io.zeebe.model.bpmn.impl.BpmnModelConstants.BPMN_ATTRIBUTE_PARTITION_ELEMENT_REF;
import static io.zeebe.model.bpmn.impl.BpmnModelConstants.BPMN_ELEMENT_LANE;

import io.zeebe.model.bpmn.instance.BaseElement;
import io.zeebe.model.bpmn.instance.FlowNode;
import io.zeebe.model.bpmn.instance.Lane;
import java.util.Collection;
import org.camunda.bpm.model.xml.ModelBuilder;
import org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext;
import org.camunda.bpm.model.xml.type.ModelElementTypeBuilder;
import org.camunda.bpm.model.xml.type.ModelElementTypeBuilder.ModelTypeInstanceProvider;
import org.camunda.bpm.model.xml.type.attribute.Attribute;
import org.camunda.bpm.model.xml.type.child.ChildElement;
import org.camunda.bpm.model.xml.type.child.SequenceBuilder;
import org.camunda.bpm.model.xml.type.reference.AttributeReference;
import org.camunda.bpm.model.xml.type.reference.ElementReferenceCollection;

/**
 * The BPMN lane element
 *
 * @author Sebastian Menski
 */
public class LaneImpl extends BaseElementImpl implements Lane {

  protected static Attribute nameAttribute;
  protected static AttributeReference partitionElementRefAttribute;
  protected static ChildElement partitionElementChild;
  protected static ElementReferenceCollection flowNodeRefCollection;
  protected static ChildElement childLaneSetChild;

  public static void registerType(ModelBuilder modelBuilder) {
    final ModelElementTypeBuilder typeBuilder =
        modelBuilder
            .defineType(Lane.class, BPMN_ELEMENT_LANE)
            .namespaceUri(BPMN20_NS)
            .extendsType(BaseElement.class)
            .instanceProvider(
                new ModelTypeInstanceProvider() {
                  @Override
                  public Lane newInstance(ModelTypeInstanceContext instanceContext) {
                    return new LaneImpl(instanceContext);
                  }
                });

    nameAttribute = typeBuilder.stringAttribute(BPMN_ATTRIBUTE_NAME).build();

    partitionElementRefAttribute =
        typeBuilder
            .stringAttribute(BPMN_ATTRIBUTE_PARTITION_ELEMENT_REF)
            .qNameAttributeReference(PartitionElement.class)
            .build();

    final SequenceBuilder sequenceBuilder = typeBuilder.sequence();

    partitionElementChild = sequenceBuilder.element(PartitionElement.class).build();

    flowNodeRefCollection =
        sequenceBuilder
            .elementCollection(FlowNodeRef.class)
            .idElementReferenceCollection(FlowNode.class)
            .build();

    childLaneSetChild = sequenceBuilder.element(ChildLaneSet.class).build();

    typeBuilder.build();
  }

  public LaneImpl(ModelTypeInstanceContext instanceContext) {
    super(instanceContext);
  }

  @Override
  public String getName() {
    return nameAttribute.getValue(this);
  }

  @Override
  public void setName(String name) {
    nameAttribute.setValue(this, name);
  }

  @Override
  public PartitionElement getPartitionElement() {
    return partitionElementRefAttribute.getReferenceTargetElement(this);
  }

  @Override
  public void setPartitionElement(PartitionElement partitionElement) {
    partitionElementRefAttribute.setReferenceTargetElement(this, partitionElement);
  }

  @Override
  public PartitionElement getPartitionElementChild() {
    return partitionElementChild.getChild(this);
  }

  @Override
  public void setPartitionElementChild(PartitionElement partitionElement) {
    partitionElementChild.setChild(this, partitionElement);
  }

  @Override
  public Collection getFlowNodeRefs() {
    return flowNodeRefCollection.getReferenceTargetElements(this);
  }

  @Override
  public ChildLaneSet getChildLaneSet() {
    return childLaneSetChild.getChild(this);
  }

  @Override
  public void setChildLaneSet(ChildLaneSet childLaneSet) {
    childLaneSetChild.setChild(this, childLaneSet);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy