public void scrollToAttribute(Attribute a) {
    if (!a.getDescriptor().getConfig().equals(getConfig())) {
      logger.fine("Cannot scroll to attribute that isn't attached to this type of descriptor");
      return;
    }
    int rowIndex = getCurrentModel().getRowForDescriptor(a.getDescriptor());
    int colIndex = getCurrentModel().getColumnForAttribute(a);
    JScrollPane scrollPane = (JScrollPane) this.getComponent(0);
    JViewport viewport = (JViewport) scrollPane.getViewport();
    EnhancedTable table = (EnhancedTable) viewport.getView();

    // This rectangle is relative to the table where the
    // northwest corner of cell (0,0) is always (0,0).
    Rectangle rect = table.getCellRect(rowIndex, colIndex, true);

    // The location of the viewport relative to the table
    Point pt = viewport.getViewPosition();

    // Translate the cell location so that it is relative
    // to the view, assuming the northwest corner of the
    // view is (0,0)
    rect.setLocation(rect.x - pt.x, rect.y - pt.y);

    // Scroll the area into view
    viewport.scrollRectToVisible(rect);
  }
Example #2
0
  public void addPM_Segment(PM_Segment segment) {
    Attribute attr = segment.getAttribute(Nomenclature.MDC_ATTR_ID_INSTNO);
    if (attr == null) return;

    InstNumber in = (InstNumber) attr.getAttributeType();
    segments.put(in.getValue(), segment);
  }
 protected String toStringExpression(JParameter arg) {
   Attribute attribute = arg.getAnnotation(Attribute.class);
   if (attribute != null) {
     return arg.getName() + "." + attribute.value();
   }
   return toStringExpression(arg.getType(), arg.getName());
 }
Example #4
0
  public void addAttribute(String nsUri, String localName, Object arg) {
    checkWritable();

    // look for the existing ones
    Attribute a;
    for (a = firstAtt; a != null; a = a.next) {
      if (a.hasName(nsUri, localName)) {
        break;
      }
    }

    // if not found, declare a new one
    if (a == null) {
      a = new Attribute(nsUri, localName);
      if (lastAtt == null) {
        assert firstAtt == null;
        firstAtt = lastAtt = a;
      } else {
        assert firstAtt != null;
        lastAtt.next = a;
        lastAtt = a;
      }
      if (nsUri.length() > 0) addNamespaceDecl(nsUri, null, true);
    }

    document.writeValue(arg, this, a.value);
  }
  @Override
  public RelationSchema getClone() {
    RelationSchema clone;

    ArrayList<Attribute> clonesAttributes = new ArrayList<>();
    ArrayList<FunctionalDependency> clonesFunctionalDependencies = new ArrayList<>();

    for (Attribute attribute : attributes) {
      clonesAttributes.add((Attribute) attribute.getClone());
    }

    for (FunctionalDependency dependency : functionalDependencies) {
      clonesFunctionalDependencies.add(dependency.getClone());
    }

    clone = new RelationSchema(name, clonesAttributes, clonesFunctionalDependencies);

    clone.setOwnId(ownId);

    clone.restoreReferences();
    clone.initPropertyChangeListeners();

    clone.setDirty(super.isDirty());

    return clone;
  }
 @Test
 public void equals_identical() {
   final Attribute a = new Blueprint().build();
   final Attribute b = new Blueprint().build();
   assertEquals(a, b);
   assertTrue(a.hashCode() == b.hashCode());
 }
 @Test
 public void equals_different_FINAL() {
   final Attribute a = new Blueprint().final1(Final.FINAL).build();
   final Attribute b = new Blueprint().final1(Final.UNDEFINED).build();
   assertFalse(a.equals(b));
   assertFalse(a.hashCode() == b.hashCode());
 }
Example #8
0
 protected void makeDecrChange(String method, Object[] args) {
   String field = methodToField(method, 4);
   Attribute attr = _dao._allAttributes.get(field);
   assert (attr != null && attr.isUpdatable())
       : "Updating an attribute that's not updatable: " + field;
   decr(attr, args == null || args.length == 0 ? 1 : args[0]);
 }
Example #9
0
 /**
  * Updates fields. Syntax: Field1=Field2; Field1=Field1+Field2;
  *
  * @param param Expresión to use
  * @param r Record
  * @return Updates record
  */
 protected Record Update(String param, Record r) throws PDException {
   if (param == null || param.length() == 0) return (r);
   String DestAttr = param.substring(0, param.indexOf('='));
   if (DestAttr.equalsIgnoreCase(PDDocs.fDOCTYPE)
       || DestAttr.equalsIgnoreCase(PDDocs.fPDID)
       || DestAttr.equalsIgnoreCase(PDDocs.fREPOSIT)
       || DestAttr.equalsIgnoreCase(PDDocs.fVERSION)
       || DestAttr.equalsIgnoreCase(PDDocs.fLOCKEDBY)
       || DestAttr.equalsIgnoreCase(PDDocs.fPDAUTOR)
       || DestAttr.equalsIgnoreCase(PDDocs.fPDDATE)
       || DestAttr.equalsIgnoreCase(PDDocs.fSTATUS))
     PDExceptionFunc.GenPDException("Attribute_not_allowed_to_change", DestAttr);
   Attribute Att = r.getAttr(DestAttr);
   String NewExp = param.substring(param.indexOf('=') + 1);
   ArrayList<String> ListElem = new ArrayList<String>(NewExp.length() / 4);
   String Current = "";
   boolean Constant = false;
   for (int i = 0; i < NewExp.length(); i++) {
     char c = NewExp.charAt(i);
     if (c != SYN_SEP && c != SYN_ADD && c != SYN_DEL) Current += c;
     else if (c == SYN_ADD || c == SYN_DEL) {
       if (Current.length() != 0) {
         ListElem.add(Current);
         Current = "";
       }
       ListElem.add("" + c);
     } else if (c == SYN_SEP) {
       Current += c;
       if (Constant) {
         ListElem.add(Current);
         Current = "";
       }
       Constant = !Constant;
     }
   }
   if (Current.length() != 0) {
     ListElem.add(Current);
     Current = "";
   }
   String TotalVal = "";
   String NewVal = "";
   Attribute Attr1 = null;
   for (int i = 0; i < ListElem.size(); i++) {
     if (i % 2 == 0) // Field
     {
       String Elem = ListElem.get(i);
       if (Elem.charAt(0) == SYN_SEP) NewVal = Elem.substring(1, Elem.length() - 1);
       else {
         Attr1 = r.getAttr(Elem);
         NewVal = Attr1.Export();
       }
       if (Current.equals("")) TotalVal = NewVal;
       else if (Current.charAt(0) == SYN_ADD) TotalVal += NewVal;
     } else {
       Current = ListElem.get(i);
     }
   }
   r.getAttr(DestAttr).setValue(TotalVal);
   return (r);
 }
  /**
   * Test entry.
   *
   * @throws Exception If the test failed unexpectedly.
   */
  @Test()
  public void testEntryToAndFromDatabase() throws Exception {
    // Make sure that the server is up and running.
    TestCaseUtils.startServer();

    // Convert the test LDIF string to a byte array
    byte[] originalLDIFBytes = StaticUtils.getBytes(ldifString);

    LDIFReader reader =
        new LDIFReader(new LDIFImportConfig(new ByteArrayInputStream(originalLDIFBytes)));

    Entry entryBefore, entryAfter;
    while ((entryBefore = reader.readEntry(false)) != null) {
      ByteString bytes = ID2Entry.entryToDatabase(entryBefore, new DataConfig(false, false, null));

      entryAfter = ID2Entry.entryFromDatabase(bytes, DirectoryServer.getDefaultCompressedSchema());

      // check DN and number of attributes
      assertEquals(entryBefore.getAttributes().size(), entryAfter.getAttributes().size());

      assertEquals(entryBefore.getDN(), entryAfter.getDN());

      // check the object classes were not changed
      for (String ocBefore : entryBefore.getObjectClasses().values()) {
        ObjectClass objectClass = DirectoryServer.getObjectClass(ocBefore.toLowerCase());
        if (objectClass == null) {
          objectClass = DirectoryServer.getDefaultObjectClass(ocBefore);
        }
        String ocAfter = entryAfter.getObjectClasses().get(objectClass);

        assertEquals(ocBefore, ocAfter);
      }

      // check the user attributes were not changed
      for (AttributeType attrType : entryBefore.getUserAttributes().keySet()) {
        List<Attribute> listBefore = entryBefore.getAttribute(attrType);
        List<Attribute> listAfter = entryAfter.getAttribute(attrType);

        assertTrue(listAfter != null);

        assertEquals(listBefore.size(), listAfter.size());

        for (Attribute attrBefore : listBefore) {
          boolean found = false;

          for (Attribute attrAfter : listAfter) {
            if (attrAfter.optionsEqual(attrBefore.getOptions())) {
              // Found the corresponding attribute

              assertEquals(attrBefore, attrAfter);
              found = true;
            }
          }

          assertTrue(found);
        }
      }
    }
    reader.close();
  }
  private static void combineWithAttribute(
      IProductDefinitionUpdate product, IAttributeDefinition attribute) throws Exception {

    List currentConfigurationList = product.getProductConfiguration();
    List newConfigurationList = new Vector();

    for (Iterator confIterator = currentConfigurationList.iterator(); confIterator.hasNext(); ) {
      IProductConfiguration productConfiguration = (IProductConfiguration) confIterator.next();

      for (Iterator attValIt = attribute.getAllowedValue().iterator(); attValIt.hasNext(); ) {
        IProductConfiguration configuration = ProductConfigurationFactory.createFacade();

        // Set static info
        configuration.setDescription(productConfiguration.getDescription());
        configuration.setGlobalPLI(productConfiguration.getGlobalPLI());
        configuration.setPermissioningSystem(productConfiguration.getPermissioningSystem());

        // Copy the source attribute configuration
        configuration.setAttribute(productConfiguration.getAttribute());

        // Add new attribute
        Attribute a = AttributeFactory.createFacade();
        a.setAttributeID(attribute.getAttributeID());
        a.setValueID(((IAllowedAttributeValue) attValIt.next()).getValueID());
        configuration.addAttribute(a);

        newConfigurationList.add(configuration);
      }
    }

    // Replace configuration list
    product.setProductConfiguration(newConfigurationList);
    currentConfigurationList = null;
  }
 /**
  * @param list
  * @exception IOException
  * @exception DicomException
  */
 public CEchoRequestCommandMessage(AttributeList list) throws DicomException, IOException {
   groupLength = Attribute.getSingleIntegerValueOrDefault(list, groupLengthTag, 0xffff);
   affectedSOPClassUID =
       Attribute.getSingleStringValueOrNull(list, TagFromName.AffectedSOPClassUID);
   commandField = Attribute.getSingleIntegerValueOrDefault(list, TagFromName.CommandField, 0xffff);
   messageID = Attribute.getSingleIntegerValueOrDefault(list, TagFromName.MessageID, 0xffff);
 }
Example #13
0
  /**
   * Read the numeric format string out of the styles table for this cell. Stores the result in the
   * Cell.
   *
   * @param startElement
   * @param cell
   */
  void setFormatString(StartElement startElement, StreamingCell cell) {
    Attribute cellStyle = startElement.getAttributeByName(new QName("s"));
    String cellStyleString = (cellStyle != null) ? cellStyle.getValue() : null;
    XSSFCellStyle style = null;

    if (cellStyleString != null) {
      style = stylesTable.getStyleAt(Integer.parseInt(cellStyleString));
    } else if (stylesTable.getNumCellStyles() > 0) {
      style = stylesTable.getStyleAt(0);
    }

    if (style != null) {
      cell.setNumericFormatIndex(style.getDataFormat());
      String formatString = style.getDataFormatString();

      if (formatString != null) {
        cell.setNumericFormat(formatString);
      } else {
        cell.setNumericFormat(BuiltinFormats.getBuiltinFormat(cell.getNumericFormatIndex()));
      }
    } else {
      cell.setNumericFormatIndex(null);
      cell.setNumericFormat(null);
    }
  }
  /**
   * A utility method which may be used by implementations in order to obtain the value of the
   * specified attribute from the provided entry as a boolean.
   *
   * @param entry The entry whose attribute is to be parsed as a boolean.
   * @param attributeType The attribute type whose value should be parsed as a boolean.
   * @return The attribute's value represented as a ConditionResult value, or
   *     ConditionResult.UNDEFINED if the specified attribute does not exist in the entry.
   * @throws DirectoryException If the value cannot be decoded as a boolean.
   */
  protected static final ConditionResult getBoolean(
      final Entry entry, final AttributeType attributeType) throws DirectoryException {
    final List<Attribute> attrList = entry.getAttribute(attributeType);
    if (attrList != null) {
      for (final Attribute a : attrList) {
        if (a.isEmpty()) {
          continue;
        }

        final String valueString = toLowerCase(a.iterator().next().getValue().toString());

        if (valueString.equals("true")
            || valueString.equals("yes")
            || valueString.equals("on")
            || valueString.equals("1")) {
          if (debugEnabled()) {
            TRACER.debugInfo(
                "Attribute %s resolves to true for user entry " + "%s",
                attributeType.getNameOrOID(), entry.getDN().toString());
          }

          return ConditionResult.TRUE;
        }

        if (valueString.equals("false")
            || valueString.equals("no")
            || valueString.equals("off")
            || valueString.equals("0")) {
          if (debugEnabled()) {
            TRACER.debugInfo(
                "Attribute %s resolves to false for user " + "entry %s",
                attributeType.getNameOrOID(), entry.getDN().toString());
          }

          return ConditionResult.FALSE;
        }

        if (debugEnabled()) {
          TRACER.debugError(
              "Unable to resolve value %s for attribute %s " + "in user entry %s as a Boolean.",
              valueString, attributeType.getNameOrOID(), entry.getDN().toString());
        }

        final Message message =
            ERR_PWPSTATE_CANNOT_DECODE_BOOLEAN.get(
                valueString, attributeType.getNameOrOID(), entry.getDN().toString());
        throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
      }
    }

    if (debugEnabled()) {
      TRACER.debugInfo(
          "Returning %s because attribute %s does not exist " + "in user entry %s",
          ConditionResult.UNDEFINED.toString(),
          attributeType.getNameOrOID(),
          entry.getDN().toString());
    }

    return ConditionResult.UNDEFINED;
  }
  private void initializeAge() {
    final Attribute attrEdu = investigator.getAttribute("EDU");
    final int baseAge = 6 + attrEdu.getUnmodifiedValue();
    NumberPicker agePicker = (NumberPicker) findViewById(R.id.tv_age);
    agePicker.setOnChangeListener(
        new OnChangedListener() {

          @Override
          public void onChanged(NumberPicker picker, int oldVal, int newVal) {
            investigator.setAge(newVal);
            int selectedAge = newVal;
            int ageDiff = selectedAge - baseAge;
            int extraEdu = ageDiff / 10;
            int currentEdu = attrEdu.getMod();
            attrEdu.setMod(extraEdu);
            if (extraEdu != currentEdu) {
              calculateDynamicSkills(attrEdu, true);
            }
            calculateDerivedAttributes();
            int newMustDrop = Math.max(0, (selectedAge / 10) - 3);
            if (newMustDrop != mustDrop) {
              mustDrop = newMustDrop;
              updateMustDrop();
            }
          }
        });
  }
Example #16
0
 public boolean containsValue(Attribute attribute) {
   if (attribute == null) {
     return false;
   }
   Object curValue = attributesMap.get(attribute.getCategory());
   return attribute.equals(curValue);
 }
 @Test
 public void equals_different_TYPE() {
   final Attribute a = new Blueprint().type(Type.of(String.class)).build();
   final Attribute b = new Blueprint().type(Type.of(Integer.class)).build();
   assertFalse(a.equals(b));
   assertFalse(a.hashCode() == b.hashCode());
 }
  private static void renderPassThruAttributesUnoptimized(
      FacesContext context,
      ResponseWriter writer,
      UIComponent component,
      Attribute[] knownAttributes,
      Map<String, List<ClientBehavior>> behaviors)
      throws IOException {

    boolean isXhtml = XHTML_CONTENT_TYPE.equals(writer.getContentType());

    Map<String, Object> attrMap = component.getAttributes();

    for (Attribute attribute : knownAttributes) {
      String attrName = attribute.getName();
      String[] events = attribute.getEvents();
      boolean hasBehavior =
          ((events != null) && (events.length > 0) && (behaviors.containsKey(events[0])));

      Object value = attrMap.get(attrName);

      if (value != null && shouldRenderAttribute(value) && !hasBehavior) {
        writer.writeAttribute(prefixAttribute(attrName, isXhtml), value, attrName);
      } else if (hasBehavior) {

        renderHandler(context, component, null, attrName, value, events[0]);
      }
    }
  }
 @Test
 public void equals_same() {
   final Attribute a = new Blueprint().build();
   assertEquals(a, a);
   assertSame(a, a);
   assertTrue(a.hashCode() == a.hashCode());
 }
Example #20
0
 public static boolean isAnywhere(Rule r) {
   if (null == r.getAttributes()) return false;
   for (Attribute any : anywheres) {
     if (any.getValue() == r.getAttribute(any.getKey())) return true;
   }
   return false;
 }
 @Test
 public void equals_different_NAME() {
   final Attribute a = new Blueprint().name("test1").build();
   final Attribute b = new Blueprint().name("test2").build();
   assertFalse(a.equals(b));
   assertFalse(a.hashCode() == b.hashCode());
 }
  /* goodG2B() - use goodsource and badsink */
  public void goodG2B_sink(String data, HttpServletRequest request, HttpServletResponse response)
      throws Throwable {

    Hashtable<String, String> env = new Hashtable<String, String>();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, "ldap://localhost:389");
    DirContext ctx = new InitialDirContext(env);

    String search =
        "(cn=" + data + ")"; /* POTENTIAL FLAW: unsanitized data from untrusted source */

    NamingEnumeration<SearchResult> answer = ctx.search("", search, null);
    while (answer.hasMore()) {
      SearchResult sr = answer.next();
      Attributes a = sr.getAttributes();
      NamingEnumeration<?> attrs = a.getAll();
      while (attrs.hasMore()) {
        Attribute attr = (Attribute) attrs.next();
        NamingEnumeration<?> values = attr.getAll();
        while (values.hasMore()) {
          response.getWriter().println(" Value: " + values.next().toString());
        }
      }
    }
  }
Example #23
0
  @Test
  public void testAtt() {
    String nsUri = "nsUri";
    String prefix = "prefix";
    String localName = "localName";
    String value = "value";

    Attribute att = new Attribute(nsUri, localName, value);

    Assert.assertEquals(nsUri, att.getNamespace());
    Assert.assertEquals(localName, att.getName());
    Assert.assertEquals(value, att.getValue());

    String nsUri2 = "nsUri2";
    String prefix2 = "prefix2";
    String localName2 = "localName2";
    String value2 = "value2";

    att.setNsURI(nsUri2);
    att.setName(localName2);
    att.setValue(value2);

    Assert.assertEquals(nsUri2, att.getNamespace());
    Assert.assertEquals(localName2, att.getName());
    Assert.assertEquals(value2, att.getValue());
  }
Example #24
0
 // 解析价格跟踪
 public static List<TradingPriceTracking> getPriceTrackingItemByItemId(String res)
     throws Exception {
   List<TradingPriceTracking> priceTrackings = new ArrayList<TradingPriceTracking>();
   Document document = formatStr2Doc(res);
   Element rootElt = document.getRootElement();
   Iterator items = rootElt.elementIterator("Item");
   while (items.hasNext()) {
     TradingPriceTracking priceTracking = new TradingPriceTracking();
     Element item = (Element) items.next();
     priceTracking.setItemid(SamplePaseXml.getSpecifyElementText(item, "ItemID"));
     priceTracking.setTitle(SamplePaseXml.getSpecifyElementText(item, "Title"));
     priceTracking.setCurrentprice(
         SamplePaseXml.getSpecifyElementText(item, "ConvertedCurrentPrice"));
     priceTracking.setBidcount(SamplePaseXml.getSpecifyElementText(item, "BidCount"));
     Element ConvertedCurrentPrice = item.element("ConvertedCurrentPrice");
     String endtime = SamplePaseXml.getSpecifyElementText(item, "EndTime");
     if (StringUtils.isNotBlank(endtime)) {
       priceTracking.setEndtime(DateUtils.returnDate(endtime));
     }
     String currencyId1 = "";
     if (ConvertedCurrentPrice != null) {
       Attribute currencyId = ConvertedCurrentPrice.attribute("currencyId");
       if (currencyId != null) {
         currencyId1 = currencyId.getValue();
       }
     }
     priceTracking.setCurrencyid(currencyId1);
     priceTrackings.add(priceTracking);
   }
   return priceTrackings;
 }
Example #25
0
  protected void populateRHS(
      Rule rule,
      PMML pmmlDocument,
      Scorecard scorecard,
      Characteristic c,
      Attribute scoreAttribute,
      int position) {
    Consequence consequence = new Consequence();
    StringBuilder stringBuilder = new StringBuilder();
    String objectClass = scorecard.getModelName().replaceAll(" ", "");

    String setter = "insertLogical(new PartialScore(\"";
    String field = ScorecardPMMLUtils.extractFieldNameFromCharacteristic(c);

    stringBuilder
        .append(setter)
        .append(objectClass)
        .append("\",\"")
        .append(field)
        .append("\",")
        .append(scoreAttribute.getPartialScore());
    if (scorecard.isUseReasonCodes()) {
      String reasonCode = scoreAttribute.getReasonCode();
      if (reasonCode == null || StringUtils.isEmpty(reasonCode)) {
        reasonCode = c.getReasonCode();
      }
      stringBuilder.append(",\"").append(reasonCode).append("\", ").append(position);
    }
    stringBuilder.append("));");
    consequence.setSnippet(stringBuilder.toString());
    rule.addConsequence(consequence);
  }
 private void setFinalBuffer(ChannelBuffer buffer) throws ErrorDataDecoderException, IOException {
   currentAttribute.addContent(buffer, true);
   String value = decodeAttribute(currentAttribute.getChannelBuffer().toString(charset), charset);
   currentAttribute.setValue(value);
   addHttpData(currentAttribute);
   currentAttribute = null;
 }
 @Override
 public void printContent(String indent) {
   System.out.println(indent + super.toString());
   indent += "  ";
   for (Attribute attribute : attributes.values()) attribute.printContent(indent);
   for (ComplexMember member : members.values()) member.printContent(indent);
 }
  public static OsgiManifest read(List<String> lines) {

    // parse lines
    OsgiManifest manifest = new OsgiManifest();
    for (int i = 0; i < lines.size(); i++) {
      String line = lines.get(i);
      for (int j = i + 1; j < lines.size() && lines.get(j).startsWith(" "); j++, i++) {
        line = line + lines.get(j);
      }
      int index = line.indexOf(':');
      if (index > 0) {
        String attributeName = line.substring(0, index).trim();
        List<String> valueTokens = tokenize(line.substring(index + 1), ',');
        Attribute values = manifest.getAttribute(attributeName);
        for (String valueToken : valueTokens) {
          if (valueToken.trim().isEmpty()) continue;
          Value value = new Value();
          values.add(value);
          List<String> annotationTokens = tokenize(valueToken, ';');
          value.setValue(annotationTokens.get(0));
          for (int k = 1; k < annotationTokens.size(); k++) {
            String annotationToken = annotationTokens.get(k);
            index = annotationToken.indexOf('=');
            if (index > 0) {
              value.setAnnotation(
                  annotationToken.substring(0, index), annotationToken.substring(index + 1));
            }
          }
        }
      }
    }
    return manifest;
  }
 private static void doAttributes(final Creature cr, final CreatureType ct) {
   int attnum = ct.attnum.aValue();
   final EnumMap<Attribute, Integer> attcap = new EnumMap<Attribute, Integer>(Attribute.class);
   for (final Attribute at : Attribute.values()) {
     if (ct.attributeCap.containsKey(at)) {
       attcap.put(at, ct.attributeCap.get(at).aValue());
     } else {
       attcap.put(at, 10);
     }
   }
   for (final Attribute a : Attribute.values()) {
     attnum -= Math.min(4, cr.skill().getAttribute(a, false));
   }
   while (attnum > 0) {
     Attribute a = i.rng.randFromArray(Attribute.values());
     if (a == WISDOM && cr.alignment() == Alignment.LIBERAL && i.rng.likely(4)) {
       a = HEART;
     }
     if (a == HEART && cr.alignment() == Alignment.CONSERVATIVE && i.rng.likely(4)) {
       a = WISDOM;
     }
     if (cr.skill().getAttribute(a, false) < attcap.get(a)) {
       cr.skill().attribute(a, +1);
       attnum--;
     }
   }
 }
Example #30
0
  // question about where viz type setting goes
  // also decide if input query goes into setting
  public static ArrayList<View> generateViewStubs(
      DBMetadata metadata,
      InputQuery targetQuery,
      InputQuery referenceQuery,
      InvocationParameters params,
      Setting setting) {
    if (params.vizSource == VizSource.MANUAL) {
      return null;
    } else { // recommendations
      if (params.comparativeVisualization) {
        ArrayList<View> views = new ArrayList<View>();
        ArrayList<Attribute> dimensions = new ArrayList<Attribute>();
        ArrayList<Attribute> measures = new ArrayList<Attribute>();

        for (Attribute a : metadata.getAttributes()) {
          // TODO: if a in targetQuery or referenceQuery, continue
          if (a.isDimension()) {
            dimensions.add(a);
          } else if (a.isMeasure()) {
            measures.add(a);
          }
        }

        // consider all combinations
        for (Attribute d : dimensions) {
          for (Attribute m : measures) {
            views.add(new AggregateComparisonView(d, m));
          }
        }
        return views;
      } else {
        return null;
      }
    }
  }