Package org.dmlite.model.config

Examples of org.dmlite.model.config.PropertyConfig


   */
  public LookupEmptyPanel(final ModelContext modelContext,
      final ViewContext viewContext) {
    super(modelContext, viewContext);
    try {
      final PropertyConfig baseEntityPropertyConfig = modelContext
          .getPropertyConfig();
      final App app = viewContext.getApp();

      if (baseEntityPropertyConfig.isReference()
          && !baseEntityPropertyConfig.isRequired()) {
        emptyLink = new Link("emptyLink") {
          static final long serialVersionUID = 200861L;
          public void onClick() {
            ModelContext entityEditFormPageModelContext = new ModelContext(
                modelContext);
            IEntity afterUpdateEntity = entityEditFormPageModelContext
                .getUpdateEntity();
            if (afterUpdateEntity != null) {
              afterUpdateEntity.setProperty(baseEntityPropertyConfig
                  .getCode(), null);
              ViewContext entityEditFormPageViewContext = new ViewContext(
                  viewContext);
              if (modelContext.getAction().equals("update")) {
                setResponsePage(app.getViewMeta().getPage(
                    "EntityEditFormPage",
                    entityEditFormPageModelContext,
                    entityEditFormPageViewContext));
              }
            }
          }
        };
        add(emptyLink);
      } else {
        throw new DmException(
            "The property is not reference or the property is required: "
                + baseEntityPropertyConfig.getCode());
      }
    } catch (DmException e) {
      log.error("Error in LookupEmptyPanel: "
          + modelContext.getEntityCode() + " - " + e.getMessage());
    }
View Full Code Here


      } else {
        entity = modelContext.getEntity();
      }
      IEntities entities = modelContext.getEntities();

      PropertyConfig propertyConfig = modelContext.getPropertyConfig();

      String propertyCode = propertyConfig.getCode();
      Class propertyClass = propertyConfig.getPropertyClassObject();

      IOrderedEntities orderedEntities = null;
      if (entities instanceof IOrderedEntities) {
        orderedEntities = (IOrderedEntities) entities;
      } else {
View Full Code Here

      final ViewContext viewContext) {
    super(viewContext.getWicketId());
    try {
      IEntity entity = modelContext.getEntity();

      PropertyConfig propertyConfig = modelContext.getPropertyConfig();
      String displayText = null;
      if (!viewContext.getMoreArgs().isEmpty()) {
        displayText = (String) viewContext.getMoreArgs().get(
            "displayText");
      }

      Class propertyClass = propertyConfig.getPropertyClassObject();
      String propertyCode = propertyConfig.getCode();
      TextHandler textExtractor = new TextHandler();
      Object property = entity.getProperty(propertyCode);
      String link;
      String linkDisplayText;
      if (entity != null) {
        if (propertyClass == URL.class) {
          URL url = (URL) property;
          if (url == null) {
            link = "";
          } else {
            link = url.toString();
          }
          if (displayText == null) {
            linkDisplayText = textExtractor
                .extractBeginPlusThreeDots(link,
                    App.SHORT_TEXT_LENGTH);
          } else {
            linkDisplayText = displayText;
          }
          externalLink = new ExternalLink("propertyValue", link,
              linkDisplayText);
          add(externalLink);
        } else if (propertyClass == Email.class) {
          Email email = (Email) property;
          if (email == null) {
            link = "";
          } else {
            link = email.toString();
          }
          if (displayText == null) {
            linkDisplayText = textExtractor
                .extractBeginPlusThreeDots(link,
                    App.SHORT_TEXT_LENGTH);
          } else {
            linkDisplayText = displayText;
          }
          externalLink = new ExternalLink("propertyValue", "mailto: " + link,
              linkDisplayText);
          add(externalLink);
        } else if (propertyClass == String.class) {
          link = (String) property;
          if (link == null) {
            link = "";
          }
          if (propertyConfig.getValidationType()
              .equals("java.net.URL")) {
            if (displayText == null) {
              linkDisplayText = textExtractor
                  .extractBeginPlusThreeDots(link,
                      App.SHORT_TEXT_LENGTH);
            } else {
              linkDisplayText = displayText;
            }
            externalLink = new ExternalLink("propertyValue", link,
                linkDisplayText);
            add(externalLink);
          } else if (propertyConfig.getValidationType().equals(
              "org.dmlite.type.email.Email")) {
            if (displayText == null) {
              linkDisplayText = textExtractor
                  .extractBeginPlusThreeDots(link,
                      App.SHORT_TEXT_LENGTH);
View Full Code Here

              .getNeighborDestinationConceptConfig();
          if (parentConceptConfig != null) {
            PropertiesConfig parentConceptPropertiesConfig = parentConceptConfig
                .getPropertiesConfig();
            for (IEntity parentPropertyConfigEntity : parentConceptPropertiesConfig) {
              PropertyConfig parentConceptPropertyConfig = (PropertyConfig) parentPropertyConfigEntity;
              if (parentConceptPropertyConfig.isEssential()) {
                IEntity parentEntity = entity
                    .getNeighborEntity(neighborConfig
                        .getCode());
                if (parentEntity != null) {
                  String parentCode = parentEntity
                      .getConceptConfig().getCode();
                  String parentPropertyKey = parentCode
                      + "."
                      + parentConceptPropertyConfig
                          .getCode();
                  String parentPropertyName = getLocalizer()
                      .getString(parentPropertyKey, this);
                  Label parentPropertyNameLabel = new Label(
                      "propertyName", parentPropertyName);
                  PropertyNameLabelValuePanelPair propertyNameLabelValuePanelPair = new PropertyNameLabelValuePanelPair();
                  propertyNameLabelValuePanelPair
                      .setPropertyNameLabel(parentPropertyNameLabel);

                  ModelContext parentModelContext = new ModelContext(
                      modelContext);
                  parentModelContext.setEntity(parentEntity);
                  parentModelContext
                      .setPropertyConfig(parentConceptPropertyConfig);

                  ViewContext parentViewContext = new ViewContext(
                      viewContext);
                  parentViewContext.setWicketId("valuePanel");

                  Panel parentPropertyValuePanel;
                  if (parentConceptPropertyConfig
                      .getPropertyClass().equals(
                          "java.net.URL")
                      || parentConceptPropertyConfig
                          .getPropertyClass()
                          .equals(
                              "org.dmlite.type.email.Email")) {
                    parentPropertyValuePanel = new ExternalLinkPanel(
                        parentModelContext,
                        parentViewContext);
                  } else {
                    parentPropertyValuePanel = new LabelPanel(
                        parentModelContext,
                        parentViewContext);
                  }
                  if (!app.isNeighborDisplayAllowed(
                      getAppSession(), neighborConfig)) {
                    parentPropertyNameLabel.setVisible(false);
                    parentPropertyValuePanel.setVisible(false);
                  } else if (!app.isPropertyDisplayAllowed(
                      getAppSession(),
                      parentConceptPropertyConfig)) {
                    parentPropertyNameLabel.setVisible(false);
                    parentPropertyValuePanel.setVisible(false);
                  }

                  propertyNameLabelValuePanelPair
                      .setPropertyValuePanel(parentPropertyValuePanel);
                  propertyNameLabelValuePanelPairs
                      .add(propertyNameLabelValuePanelPair);
                } // if
              } // if
            } // for
          } // if
        } // if
      } // for

      PropertiesConfig propertiesConfig = conceptConfig
          .getPropertiesConfig();
      for (IEntity propertyConfigEntity : propertiesConfig) {
        PropertyConfig propertyConfig = (PropertyConfig) propertyConfigEntity;
        if (!propertyConfig.isReference()) {
          String propertyKey = conceptConfig.getCode() + "."
              + propertyConfig.getCode();
          String propertyName = getLocalizer().getString(propertyKey,
              this);
          Label propertyNameLabel = new Label("propertyName",
              propertyName);
          PropertyNameLabelValuePanelPair propertyNameLabelValuePanelPair = new PropertyNameLabelValuePanelPair();
          propertyNameLabelValuePanelPair
              .setPropertyNameLabel(propertyNameLabel);
          entityContext.setPropertyConfig(propertyConfig);
          ViewContext propertiesViewContext = new ViewContext(
              viewContext);
          propertiesViewContext.setWicketId("valuePanel");
          Panel propertyValuePanel;
          if (propertyConfig.getPropertyClass()
              .equals("java.net.URL")
              || propertyConfig.getPropertyClass().equals(
                  "org.dmlite.type.email.Email")) {
            propertyValuePanel = new ExternalLinkPanel(entityContext,
                propertiesViewContext);
          } else if (propertyConfig.getPropertyClass().equals(
              "java.lang.String")
              && propertyConfig.isValidateType()
              && (propertyConfig.getValidationType().equals(
                  "java.net.URL") || propertyConfig
                  .getValidationType().equals(
                      "org.dmlite.type.email.Email"))) {

            propertyValuePanel = new ExternalLinkPanel(entityContext,
                propertiesViewContext);

          } else if (propertyConfig.getPropertyClass().equals(
              "java.lang.Boolean")) {
            propertyValuePanel = new CheckBoxPanel(entityContext,
                propertiesViewContext);

          } else if (propertyConfig.getPropertyClass().equals(
              "java.lang.String")
              && propertyConfig.getDisplayLengthInt() > App.MIN_LONG_TEXT_LENGTH) {
            propertyValuePanel = new MultiLineLabelPanel(entityContext,
                propertiesViewContext);

          } else {
            propertyValuePanel = new LabelPanel(entityContext,
View Full Code Here

              .getNeighborDestinationConceptConfig();
          if (parentConceptConfig != null) {
            PropertiesConfig parentConceptPropertiesConfig = parentConceptConfig
                .getPropertiesConfig();
            for (IEntity propertyConfigEntity : parentConceptPropertiesConfig) {
              PropertyConfig parentConceptPropertyConfig = (PropertyConfig) propertyConfigEntity;
              if (parentConceptPropertyConfig.isEssential()) {
                IEntity parentEntity = entity
                    .getNeighborEntity(neighborConfig
                        .getCode());
                if (parentEntity != null) {
                  String parentCode = parentEntity
                      .getConceptConfig().getCode();
                  String parentPropertyKey = parentCode
                      + "."
                      + parentConceptPropertyConfig
                          .getCode();
                  String parentPropertyName = getLocalizer()
                      .getString(parentPropertyKey, this);
                  Label parentPropertyNameLabel = new Label(
                      "propertyName", parentPropertyName);
                  PropertyNameLabelValuePanelPair propertyNameLabelValuePanelPair = new PropertyNameLabelValuePanelPair();
                  propertyNameLabelValuePanelPair
                      .setPropertyNameLabel(parentPropertyNameLabel);

                  ModelContext parentModelContext = new ModelContext(
                      modelContext);
                  parentModelContext.setEntity(parentEntity);
                  parentModelContext
                      .setPropertyConfig(parentConceptPropertyConfig);

                  ViewContext parentViewContext = new ViewContext(
                      viewContext);
                  parentViewContext.setWicketId("valuePanel");

                  Panel parentPropertyValuePanel;
                  if (parentConceptPropertyConfig
                      .getPropertyClass().equals(
                          "java.net.URL")
                      || parentConceptPropertyConfig
                          .getPropertyClass()
                          .equals(
                              "org.dmlite.type.email.Email")) {
                    parentPropertyValuePanel = new ExternalLinkPanel(
                        parentModelContext,
                        parentViewContext);
                  } else {
                    parentPropertyValuePanel = new LabelPanel(
                        parentModelContext,
                        parentViewContext);
                  }
                  if (!app.isNeighborDisplayAllowed(
                      getAppSession(), neighborConfig)) {
                    parentPropertyNameLabel.setVisible(false);
                    parentPropertyValuePanel.setVisible(false);
                  } else if (!app.isPropertyDisplayAllowed(
                      getAppSession(),
                      parentConceptPropertyConfig)) {
                    parentPropertyNameLabel.setVisible(false);
                    parentPropertyValuePanel.setVisible(false);
                  }

                  propertyNameLabelValuePanelPair
                      .setPropertyValuePanel(parentPropertyValuePanel);
                  propertyNameLabelValuePanelPairs
                      .add(propertyNameLabelValuePanelPair);
                } // if
              } // if
            } // for
          } // if
        } // if
      } // for

      PropertiesConfig propertiesConfig = conceptConfig
          .getPropertiesConfig();
      for (IEntity config : propertiesConfig) {
        PropertyConfig propertyConfig = (PropertyConfig) config;
        String propertyCode = propertyConfig.getCode();
        String propertyKey = conceptConfig.getCode() + "."
            + propertyCode;
        String propertyName = getLocalizer().getString(propertyKey,
            this);
        PropertyNameLabelValuePanelPair propertyNameLabelValuePanelPair = new PropertyNameLabelValuePanelPair();
        Label propertyNameLabel = new Label("propertyName",
            propertyName);
        propertyNameLabelValuePanelPair
            .setPropertyNameLabel(propertyNameLabel);
        ModelContext entityModelContext = new ModelContext(modelContext);
        entityModelContext.setPropertyConfig(propertyConfig);
        Panel propertyValuePanel;
        if (propertyConfig.getPropertyClass().equals(
            "java.lang.Boolean")) {
          ViewContext checkBoxPanelContext = new ViewContext(
              viewContext);
          checkBoxPanelContext.setWicketId("valuePanel");
          propertyValuePanel = new CheckBoxPanel(entityModelContext,
              checkBoxPanelContext);
        } else if (propertyConfig.getPropertyClass().equals(
            "java.lang.String")
            && propertyConfig.getDisplayLengthInt() > App.MIN_LONG_TEXT_LENGTH) {
          ViewContext textAreaPanelContext = new ViewContext(
              viewContext);
          textAreaPanelContext.setWicketId("valuePanel");
          propertyValuePanel = new TextAreaPanel(entityModelContext,
              textAreaPanelContext);
        } else if (propertyConfig.isReference()) {
          String neighborCode = propertyConfig.getReferenceNeighbor();
          NeighborConfig neighborConfig = conceptConfig
              .getNeighborsConfig().getNeighborConfig(
                  neighborCode);
          String neighborConceptCode = neighborConfig
              .getDestination();
          IPersistentEntities persistentEntities = app.getDbContext()
              .getPersistentModel().getPersistentEntry(
                  neighborConceptCode);
          IOrderedEntities lookupEntities = null;
          if (persistentEntities != null) {
            lookupEntities = (IOrderedEntities) persistentEntities
                .getEntities();
          }
          if (lookupEntities != null) {
            ModelContext neighborModelContext = new ModelContext(
                modelContext);
            neighborModelContext.setPropertyConfig(propertyConfig);
            neighborModelContext.setLookupEntities(lookupEntities);
            ViewContext lookupViewContext = new ViewContext(
                viewContext);
            lookupViewContext.setWicketId("valuePanel");
            if (neighborConfig.getMinInt() == 0) {
              propertyValuePanel = new LookupEmptyPanel(
                  neighborModelContext, lookupViewContext);

            } else {
              propertyValuePanel = new LookupPanel(
                  neighborModelContext, lookupViewContext);
            }
          } else {
            ViewContext textFieldPanelContext = new ViewContext(
                viewContext);
            textFieldPanelContext.setWicketId("valuePanel");
            propertyValuePanel = new TextFieldPanel(entityModelContext,
                textFieldPanelContext);
          }
        } else if (propertyConfig.isValidateType()
            && propertyConfig
                .isValidatationTypeEntities(domainModel)) {
          ViewContext dropDownChoicePanelContext = new ViewContext(
              viewContext);
          dropDownChoicePanelContext.setWicketId("valuePanel");
          propertyValuePanel = new TypeValueDropDownChoicePanel(
View Full Code Here

          .getPropertiesConfig();
      IDomainModel domainModel = getDomainModel();
      if (domainModel != null) {
        ModelMeta modelMeta = domainModel.getModelMeta();
        for (PropertyConfig config : propertiesConfig) {
          PropertyConfig propertyConfig = (PropertyConfig) config;
          String propertyCode = propertyConfig.getCode();
          Object afterProperty = updateEntity
              .getProperty(propertyCode);
          if (propertyConfig.isRequired()) {
            if (afterProperty != null) {
              if (propertyConfig.isValidateType()) {
                validation = modelMeta.validPropertyType(this,
                    updateEntity, propertyConfig,
                    afterProperty)
                    && validation;
              }
            } else {
              modelMeta.addRequiredPropertyError(this, entity,
                  propertyConfig);
              validation = false;
            }
          } else if (afterProperty != null) {
            if (propertyConfig.isValidateType()) {
              validation = modelMeta
                  .validPropertyType(this, updateEntity,
                      propertyConfig, afterProperty)
                  && validation;
            }
View Full Code Here

      ViewContext childViewContext = new ViewContext(viewContext, true);
      childViewContext.setWicketId("childProperty");

      String childProperty = (String) modelContext.getMoreArgs().get(
          "childProperty");
      PropertyConfig childPropertyConfig = childEntity.getConceptConfig()
          .getPropertyConfig(childProperty);
      Panel childPropertyPanel;
      String propertyType = childPropertyConfig.getPropertyClass();
      if (propertyType.equals("java.net.URL")
          || propertyType.equals("org.dmlite.type.email.Email")) {
        childPropertyPanel = new ExternalLinkPanel(childModelContext,
            childViewContext);
        item.add(childPropertyPanel);
      } else if (childPropertyConfig.getPropertyClass().equals(
          "java.lang.String")
          && childPropertyConfig.isValidateType()
          && (childPropertyConfig.getValidationType().equals(
              "java.net.URL") || childPropertyConfig
              .getValidationType().equals(
                  "org.dmlite.type.email.Email"))) {
        childPropertyPanel = new ExternalLinkPanel(childModelContext,
            childViewContext);
        item.add(childPropertyPanel);
View Full Code Here

    super(modelContext, viewContext);
    try {
      App app = viewContext.getApp();
     
      IEntities entities = modelContext.getEntities();
      PropertyConfig propertyConfig = modelContext.getPropertyConfig();

      String keywords = (String) viewContext.getMoreArgs()
          .get("keywords");
      Boolean andKeywords = (Boolean) viewContext.getMoreArgs().get(
          "andKeywords");

      IEntities entitiesThatContainKeywords = null;
      keywords.trim();
      if (keywords.equals("")) {
        entitiesThatContainKeywords = entities;
      } else {
        String[] keywordsArray = keywords.split(",");
        if (andKeywords.booleanValue()) {
          SelectionCriteria criteria = SelectionCriteria
              .defineContainAllCriteria(propertyConfig.getCode(),
                  keywordsArray);
          entitiesThatContainKeywords = (IOrderedEntities) entities
              .getEntities(criteria);
        } else {
          SelectionCriteria criteria = SelectionCriteria
              .defineContainSomeCriteria(
                  propertyConfig.getCode(), keywordsArray);
          entitiesThatContainKeywords = (IOrderedEntities) entities
              .getEntities(criteria);
        }
      }
View Full Code Here

        conceptConfig = getEntities().getConceptConfig();
      } else if (getEntity() != null) {
        conceptConfig = getEntity().getConceptConfig();
      }
      if (conceptConfig != null) {
        PropertyConfig propertyConfig = conceptConfig
            .getPropertiesConfig().getPropertyConfig(propertyCode);
        if (propertyConfig != null) {
          setPropertyConfig(propertyConfig);
        }
      }
View Full Code Here

     
      ConceptConfig conceptConfig = modelContext.getEntities()
          .getConceptConfig();
      String conceptCode = conceptConfig.getCode();

      PropertyConfig propertyConfig = modelContext.getPropertyConfig();
      String propertyCode = propertyConfig.getCode();
      String propertyKey = conceptCode + "." + propertyCode;
      String propertyName = getLocalizer().getString(propertyKey, this);
      String select = getLocalizer().getString("select", this);
      String title = propertyName + ": " + select;
View Full Code Here

TOP

Related Classes of org.dmlite.model.config.PropertyConfig

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.