Package it.eng.qbe.model.properties

Examples of it.eng.qbe.model.properties.IModelProperties


    ISelectField field;
    String fieldUniqueName;
    IModelField datamartField;
    JSONObject fieldJSON;
    Iterator it;
    IModelProperties datamartLabels;
    String label, longDescription;
   
    logger.debug("IN");
   
    try {
      datamartLabels = null;
      if(locale != null) {
        //datamartLabels =  QbeCacheManager.getInstance().getLabels( dataSource , locale );
        datamartLabels = dataSource.getModelI18NProperties(locale);
      }
     
      fields = query.getSelectFields(false);
      Assert.assertNotNull(fields, "Fields cannot be null");
      logger.debug("Query [" + query.getId() + "] have [" + fields.size() + "] field/s to serialize");
     
      result = new JSONArray();
      it = fields.iterator();
      while( it.hasNext() ) {
        field = (ISelectField)it.next();
        logger.debug("Serializing filed [" + field.getAlias() + "]");
        try {
          fieldJSON = new JSONObject();
         
          fieldJSON.put(QuerySerializationConstants.FIELD_ALIAS, field.getAlias());
         
          fieldJSON.put(QuerySerializationConstants.FIELD_VISIBLE, field.isVisible());
          fieldJSON.put(QuerySerializationConstants.FIELD_INCLUDE, field.isIncluded());         
         
          // field nature can me "measure" or "attribute"
          String nature = null;
         
          if (field.isDataMartField()) {
            DataMartSelectField dataMartSelectField = (DataMartSelectField)field;
           
            fieldJSON.put(QuerySerializationConstants.FIELD_TYPE, field.DATAMART_FIELD);
           
            fieldUniqueName = dataMartSelectField.getUniqueName();
            datamartField = dataSource.getModelStructure().getField( fieldUniqueName );
            Assert.assertNotNull(datamartField, "A filed named [" + fieldUniqueName + "] does not exist in the datamart model");
           
            fieldJSON.put(QuerySerializationConstants.FIELD_ID, datamartField.getUniqueName());
                       
            // localize entity name
            label = null;
            if(datamartLabels != null) {
              label = datamartLabels.getProperty(datamartField.getParent(), "label");
            }
            label = StringUtilities.isEmpty(label)? datamartField.getParent().getName(): label;
            fieldJSON.put(QuerySerializationConstants.FIELD_ENTITY, label);
           
            // localize field name
            label = null;
            if(datamartLabels != null) {
              label = datamartLabels.getProperty(datamartField, "label");
            }
            label = StringUtilities.isEmpty(label)? datamartField.getName(): label;
            fieldJSON.put(QuerySerializationConstants.FIELD_NAME, label);
            longDescription = getFieldLongDescription(datamartField, datamartLabels);
            fieldJSON.put(QuerySerializationConstants.FIELD_LONG_DESCRIPTION, longDescription);
View Full Code Here


    WhereField.Operand operand;
    JSONObject filterJSON;
    IModelField datamartFilter;
    String fieldUniqueName;
    Iterator it;
    IModelProperties datamartLabels;
    IModelField datamartField;
   
    filters = query.getWhereFields();
    Assert.assertNotNull(filters, "Filters cannot be null");
   
    datamartLabels = null;
    if(locale != null) {
      //datamartLabels =  QbeCacheManager.getInstance().getLabels( dataSource , locale );
      datamartLabels = dataSource.getModelI18NProperties(locale);
    }
   
    it = filters.iterator();
    while( it.hasNext() ) {
      filter = (WhereField)it.next();
     
      filterJSON = new JSONObject();
      try {
        filterJSON.put(QuerySerializationConstants.FILTER_ID, filter.getName());
        filterJSON.put(QuerySerializationConstants.FILTER_DESCRIPTION, filter.getDescription());
        filterJSON.put(QuerySerializationConstants.FILTER_PROMPTABLE, filter.isPromptable());
       
        operand = filter.getLeftOperand();
        filterJSON.put(QuerySerializationConstants.FILTER_LO_VALUE, operand.values[0]);
        if(operand.type.equalsIgnoreCase("Field Content")) {
          if(operand.values[0].contains("\"expression\":\"")){
            filterJSON.put(QuerySerializationConstants.FILTER_LO_DESCRIPTION, operand.description );
            String description = operand.values[0].substring(operand.values[0].indexOf("\"expression\":\"")+14);
            description.substring(0, description.indexOf("\""));
            filterJSON.put(QuerySerializationConstants.FILTER_LO_LONG_DESCRIPTION, description);           
          }else{
            datamartField = dataSource.getModelStructure().getField( operand.values[0] );
           
            String labelF, labelE;
            labelE = null;
            if(datamartLabels != null) {
              labelE = datamartLabels.getProperty(datamartField.getParent(), "label");
            }
            labelE = StringUtilities.isEmpty(labelE)? datamartField.getParent().getName(): labelE;
           
           
            labelF = null;
            if(datamartLabels != null) {
              labelF = datamartLabels.getProperty(datamartField, "label");
            }
            labelF = StringUtilities.isEmpty(labelF)? datamartField.getName(): labelF;
           
            filterJSON.put(QuerySerializationConstants.FILTER_LO_DESCRIPTION, labelE  + " : " + labelF );
           
            String loLongDescription = getFieldLongDescription(datamartField, datamartLabels);
            filterJSON.put(QuerySerializationConstants.FILTER_LO_LONG_DESCRIPTION, loLongDescription);
          }
        } else if(operand.type.equalsIgnoreCase("Subquery")) {
          String loLongDescription = "Subquery " + operand.description;
          filterJSON.put(QuerySerializationConstants.FILTER_LO_LONG_DESCRIPTION, loLongDescription);
         
          filterJSON.put(QuerySerializationConstants.FILTER_LO_DESCRIPTION, operand.description);
        } else if(operand.type.equalsIgnoreCase("Parent Field Content")) {
          String[] chunks = operand.values[0].split(" ");
          String parentQueryId = chunks[0];
          String fieldName = chunks[1];
          datamartField = dataSource.getModelStructure().getField( fieldName );
          String datamartFieldLongDescription = getFieldLongDescription(datamartField, datamartLabels);
          String loLongDescription = "Query " + parentQueryId + ", " + datamartFieldLongDescription;
          filterJSON.put(QuerySerializationConstants.FILTER_LO_LONG_DESCRIPTION, loLongDescription);
         
          filterJSON.put(QuerySerializationConstants.FILTER_LO_DESCRIPTION, operand.description);
        } else {
          filterJSON.put(QuerySerializationConstants.FILTER_LO_DESCRIPTION, operand.description);
        }
       
       
       
        filterJSON.put(QuerySerializationConstants.FILTER_LO_TYPE, operand.type);
        filterJSON.put(QuerySerializationConstants.FILTER_LO_DEFAULT_VALUE, operand.defaulttValues[0]);
        filterJSON.put(QuerySerializationConstants.FILTER_LO_LAST_VALUE, operand.lastValues[0]);
       
        filterJSON.put(QuerySerializationConstants.FILTER_OPERATOR, filter.getOperator());
       
        operand = filter.getRightOperand();
        filterJSON.put(QuerySerializationConstants.FILTER_RO_VALUE, JSONUtils.asJSONArray(operand.values));
        if(operand.type.equalsIgnoreCase("Field Content")) {
          datamartField = dataSource.getModelStructure().getField( operand.values[0] );
         
          String labelF, labelE;
          labelE = null;
          if(datamartLabels != null) {
            labelE = datamartLabels.getProperty(datamartField.getParent(), "label");
          }
          labelE = StringUtilities.isEmpty(labelE)? datamartField.getParent().getName(): labelE;
         
         
          labelF = null;
          if(datamartLabels != null) {
            labelF = datamartLabels.getProperty(datamartField, "label");
          }
          labelF = StringUtilities.isEmpty(labelF)? datamartField.getName(): labelF;
         
          filterJSON.put(QuerySerializationConstants.FILTER_RO_DESCRIPTION, labelE  + " : " + labelF );
         
View Full Code Here

    HavingField.Operand operand;
    JSONObject havingJSON;
    IModelField datamartFilter;
    String fieldUniqueName;
    Iterator it;
    IModelProperties datamartLabels;
    IModelField datamartField;
   
    havings = query.getHavingFields();
    Assert.assertNotNull(havings, "Filters cannot be null");
   
    datamartLabels = null;
    if(locale != null) {
      //datamartLabels =  QbeCacheManager.getInstance().getLabels( dataSource , locale );
      datamartLabels = dataSource.getModelI18NProperties(locale);
    }
   
    it = havings.iterator();
    while( it.hasNext() ) {
      filter = (HavingField)it.next();
     
      havingJSON = new JSONObject();
      try {
        havingJSON.put(QuerySerializationConstants.FILTER_ID, filter.getName());
        havingJSON.put(QuerySerializationConstants.FILTER_DESCRIPTION, filter.getDescription());
        havingJSON.put(QuerySerializationConstants.FILTER_PROMPTABLE, filter.isPromptable());
       
        operand = filter.getLeftOperand();
        havingJSON.put(QuerySerializationConstants.FILTER_LO_VALUE, operand.values[0]);
        if(operand.type.equalsIgnoreCase("Field Content")) {
         
          if(operand.values[0].contains("\"expression\":\"")){
            havingJSON.put(QuerySerializationConstants.FILTER_LO_DESCRIPTION, operand.description );
            String description = operand.values[0].substring(operand.values[0].indexOf("\"expression\":\"")+14);
            description.substring(0, description.indexOf("\""));
            havingJSON.put(QuerySerializationConstants.FILTER_LO_LONG_DESCRIPTION, description);           
          }else{
         
            datamartField = dataSource.getModelStructure().getField( operand.values[0] );
           
            String labelF, labelE;
            labelE = null;
            if(datamartLabels != null) {
              labelE = datamartLabels.getProperty(datamartField.getParent(), "label");
            }
            labelE = StringUtilities.isEmpty(labelE)? datamartField.getParent().getName(): labelE;
           
           
            labelF = null;
            if(datamartLabels != null) {
              labelF = datamartLabels.getProperty(datamartField, "label");
            }
            labelF = StringUtilities.isEmpty(labelF)? datamartField.getName(): labelF;
           
            havingJSON.put(QuerySerializationConstants.FILTER_LO_DESCRIPTION, labelE  + " : " + labelF );
           
            String loLongDescription = getFieldLongDescription(datamartField, datamartLabels);
            havingJSON.put(QuerySerializationConstants.FILTER_LO_LONG_DESCRIPTION, loLongDescription);
 
         
         
        } else if(operand.type.equalsIgnoreCase("Subquery")) {
          String loLongDescription = "Subquery " + operand.description;
          havingJSON.put(QuerySerializationConstants.FILTER_LO_LONG_DESCRIPTION, loLongDescription);
         
          havingJSON.put(QuerySerializationConstants.FILTER_LO_DESCRIPTION, operand.description);
        } else if(operand.type.equalsIgnoreCase("Parent Field Content")) {
          String[] chunks = operand.values[0].split(" ");
          String parentQueryId = chunks[0];
          String fieldName = chunks[1];
          datamartField = dataSource.getModelStructure().getField( fieldName );
          String datamartFieldLongDescription = getFieldLongDescription(datamartField, datamartLabels);
          String loLongDescription = "Query " + parentQueryId + ", " + datamartFieldLongDescription;
          havingJSON.put(QuerySerializationConstants.FILTER_LO_LONG_DESCRIPTION, loLongDescription);
         
          havingJSON.put(QuerySerializationConstants.FILTER_LO_DESCRIPTION, operand.description);
        } else {
          havingJSON.put(QuerySerializationConstants.FILTER_LO_DESCRIPTION, operand.description);
        }
       
       
       
        havingJSON.put(QuerySerializationConstants.FILTER_LO_TYPE, operand.type);
        havingJSON.put(QuerySerializationConstants.FILTER_LO_FUNCTION, operand.function.getName());
        havingJSON.put(QuerySerializationConstants.FILTER_LO_DEFAULT_VALUE, operand.defaulttValues[0]);
        havingJSON.put(QuerySerializationConstants.FILTER_LO_LAST_VALUE, operand.lastValues[0]);
       
        havingJSON.put(QuerySerializationConstants.FILTER_OPERATOR, filter.getOperator());
       
        operand = filter.getRightOperand();
        havingJSON.put(QuerySerializationConstants.FILTER_RO_VALUE, JSONUtils.asJSONArray(operand.values));
        if(operand.type.equalsIgnoreCase("Field Content")) {
          datamartField = dataSource.getModelStructure().getField( operand.values[0] );
         
          String labelF, labelE;
          labelE = null;
          if(datamartLabels != null) {
            labelE = datamartLabels.getProperty(datamartField.getParent(), "label");
          }
          labelE = StringUtilities.isEmpty(labelE)? datamartField.getParent().getName(): labelE;
         
         
          labelF = null;
          if(datamartLabels != null) {
            labelF = datamartLabels.getProperty(datamartField, "label");
          }
          labelF = StringUtilities.isEmpty(labelF)? datamartField.getName(): labelF;
         
          havingJSON.put(QuerySerializationConstants.FILTER_RO_DESCRIPTION, labelE  + " : " + labelF );
         
View Full Code Here

  public void setName(String name) {
    this.name = name;
  }
 
  public IModelProperties getModelI18NProperties(Locale locale) {
    IModelProperties properties;
   
    if(modelPropertiesCache == null) {
      modelPropertiesCache = new HashMap<String, IModelProperties>();
    }
   
View Full Code Here

      fail();
    }
  }

  public void doTestLabelLocalization() {
    IModelProperties properties;
    String label;
    IModelEntity entity = dataSource.getModelStructure().getEntity(testEntityUniqueName);
   
    properties = dataSource.getModelI18NProperties(Locale.ITALIAN);
    label = properties.getProperty(entity, "label");
    assertTrue("[" + label + "] is not equal to [" + "Customer Italiano" + "]", "Customer Italiano".equals(label));
   
    properties = dataSource.getModelI18NProperties(Locale.ENGLISH);
    label = properties.getProperty(entity, "label");
    assertTrue("[" + label + "] is not equal to [" + "Customer Inglese" + "]", "Customer Inglese".equals(label));
   
    properties = dataSource.getModelI18NProperties(Locale.JAPANESE);
    label = properties.getProperty(entity, "label");
    assertTrue("[" + label + "] is not equal to [" + "Customer Default" + "]", "Customer Default".equals(label));
  }
View Full Code Here

    label = properties.getProperty(entity, "label");
    assertTrue("[" + label + "] is not equal to [" + "Customer Default" + "]", "Customer Default".equals(label));
  }
 
  public void doTestTooltipLocalization() {
    IModelProperties properties;
    String tooltip;
    IModelEntity entity = dataSource.getModelStructure().getEntity(testEntityUniqueName);
   
    properties = dataSource.getModelI18NProperties(Locale.ITALIAN);
    tooltip = properties.getProperty(entity, "tooltip");
    assertTrue("[" + tooltip + "] is not equal to [" + "Customer Italiano" + "]", "Customer Italiano".equals(tooltip));
   
    properties = dataSource.getModelI18NProperties(Locale.ENGLISH);
    tooltip = properties.getProperty(entity, "tooltip");
    assertTrue("[" + tooltip + "] is not equal to [" + "Customer Inglese" + "]", "Customer Inglese".equals(tooltip));
   
    properties = dataSource.getModelI18NProperties(Locale.JAPANESE);
    tooltip = properties.getProperty(entity, "tooltip");
    assertTrue("[" + tooltip + "] is not equal to [" + "Customer Default" + "]", "Customer Default".equals(tooltip));
  }
View Full Code Here

  public IModelProperties loadModelProperties() {
    SimpleModelProperties properties = new SimpleModelProperties();
    Iterator<IDataSourceConfiguration> it = subConfigurations.iterator();
    while (it.hasNext()) {
      IDataSourceConfiguration configuration = it.next();
      IModelProperties props = configuration.loadModelProperties();
      properties.putAll(props);
    }
   
    return properties;
  }
View Full Code Here

  public SimpleModelProperties loadModelI18NProperties(Locale locale) {
    SimpleModelProperties properties = new SimpleModelProperties();
    Iterator<IDataSourceConfiguration> it = subConfigurations.iterator();
    while (it.hasNext()) {
      IDataSourceConfiguration subModelConfiguration = it.next();
      IModelProperties subModelProperties = subModelConfiguration.loadModelI18NProperties(locale);
      properties.putAll(subModelProperties);
    }
   
    return properties;
  }
View Full Code Here

  public IModelProperties loadModelI18NProperties(Locale locale) {
    if(i18nMap == null) {
      i18nMap = new HashMap<Locale, IModelProperties>();
    }
   
    IModelProperties p = i18nMap.get(locale);
    if(p == null) {
      i18nMap.put(locale, super.loadModelI18NProperties(locale));
    }
    return i18nMap.get(locale);
  }
View Full Code Here

TOP

Related Classes of it.eng.qbe.model.properties.IModelProperties

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.