/** * This method will check that replacing the current DE with a mapping to existing DE will not * conflict with any other DE. * * @param oldDe currentMapping * @param newDe new Mapping * @return null if there is no conflict. The conflicting DE if there is a conflict. */ public static DataElement checkConflict(DataElement oldDe, DataElement newDe) { ObjectClass oc = oldDe.getDataElementConcept().getObjectClass(); if (oc.getPublicId() != null) { // Verify conflicts if (!newDe.getDataElementConcept().getObjectClass().getPublicId().equals(oc.getPublicId()) || !newDe.getDataElementConcept().getObjectClass().getVersion().equals(oc.getVersion())) { // Oc was already mapped by an existing DE. This DE conflicts with the previous mapping. // Now we need to find out what DE set the oc_id previously // return newDe; List<DataElement> des = ElementsLists.getInstance().getElements(DomainObjectFactory.newDataElement()); for (DataElement de : des) { if (de.getDataElementConcept().getObjectClass() != oldDe.getDataElementConcept().getObjectClass()) continue; if (StringUtil.isEmpty(de.getPublicId()) || de.getVersion() == null) continue; String ocId = de.getDataElementConcept().getObjectClass().getPublicId(); if (oldDe != de && ocId != null && !ocId.equals(newDe.getDataElementConcept().getObjectClass().getPublicId())) { return de; } } // we shouldn't be here return null; } } return null; }
protected String getField( Segment pSegment, int pFieldNum, boolean pMandatoryFl, String pErrorMessage) { DataElement de = null; String val = null; String err = null; try { de = pSegment.getDataElement(pFieldNum); } catch (Exception exc) { if (pMandatoryFl) { err = pErrorMessage + " (1)"; } } if (err == null && de == null && pMandatoryFl) { err = pErrorMessage + " (2)"; } if (err == null && de != null) { try { val = de.get(); } catch (Exception exc) { } if (!Utility.isSet(val) && pMandatoryFl) { err = pErrorMessage + " (3)"; } } if (err != null) { errorMsgs.add(err); } return val; }
/** * Replaces the {@link DataElement} at the specified index. After the element has been * successfully replaced all {@link DataListener DataListeners} will be informed. * * @param index Index of the element which will be replaced by <tt>element</tt>. * @param element The new <tt>DataElement</tt>. * @throws IllegalArgumentException if <tt>element</tt> is not of the correct type which will be * checked by the method {@link #isValid}. */ public void replaceElementAt(int index, DataElement element) { if (isValid(element)) { DataElement oldElement = (DataElement) _container.elementAt(index); oldElement.setContainer(null); _container.setElementAt(element, index); element.setContainer(this); notifyListeners(DataEvent.createReplaceEvent(this, index, oldElement)); } else { throwException(REPLACE, element); } }
private DataSet applyfactorScale(DataSet dataSet, double factorScale) { Enumeration<DataElement> elements = dataSet.getDataElements(); while (elements.hasMoreElements()) { DataElement element = elements.nextElement(); if (factorScale != 0) { BigDecimal qty = (BigDecimal) element.getValue(); BigDecimal value = qty.multiply(new BigDecimal(factorScale)).divide(new BigDecimal(100)); String desc = element.getDescription() + " Scale :" + value.toString(); element.setValue(value); element.setDescription(desc); } } return dataSet; }
/** * Inserts a {@link DataElement} at the specified index. After the element has been successfully * inserted all {@link DataListener DataListeners} will be informed. * * @param index Index at which <tt>element</tt> will be inserted. All elements with an index >= * <tt>index</tt> will be shifted. * @param element DataElement to be added. * @throws IllegalArgumentException if <tt>element</tt> is not of the correct type which will be * checked by the method {@link #isValid}. */ public void insertElementAt(int index, DataElement element) { if (isValid(element)) { _container.insertElementAt(element, index); element.setContainer(this); notifyListeners(DataEvent.createInsertEvent(this, index)); } else { throwException(INSERT, element); } }
/** * Adds a {@link DataElement}. After the element has been successfully added all {@link * DataListener DataListeners} will be informed. * * @param element DataElement to be added. * @throws IllegalArgumentException if <tt>element</tt> is not of the correct type which will be * checked by the method {@link #isValid}. */ public void addElement(DataElement element) { if (isValid(element)) { _container.addElement(element); element.setContainer(this); notifyListeners(DataEvent.createAddEvent(this)); } else { throwException(ADD, element); } }
private void endDataElement() throws SAXException { DataElement el = getLastDataElement(); if (!values.isEmpty()) { try { if (el.vr.isIntType()) el.setValues(parseInts(values)); else el.setValues(values.toArray(new String[values.size()])); } catch (IllegalStateException e) { throw new SAXException("unexpected <Value>"); } values.clear(); } if (!codes.isEmpty()) { try { el.setValues(codes.toArray(new Code[codes.size()])); } catch (IllegalStateException e) { throw new SAXException("unexpected <Code>"); } codes.clear(); } elementConditions = false; }
public static AdminComponent checkDuplicate(DataElement currentDe, DataElement newDataElement) { ElementsLists elements = ElementsLists.getInstance(); // 1. Verify that this DE will not implicitely map the OC to one // that is already used in the model. List<ObjectClass> ocs = elements.getElements(DomainObjectFactory.newObjectClass()); if (ocs != null) { for (ObjectClass oc : ocs) { if (oc.getPublicId() != null) { if (currentDe.getDataElementConcept().getObjectClass() != oc) if (oc.getPublicId() .equals(newDataElement.getDataElementConcept().getObjectClass().getPublicId())) return oc; } } } // 2. Check that we don't already have this exact DE public ID List<DataElement> des = elements.getElements(DomainObjectFactory.newDataElement()); for (DataElement de : des) { if (de != currentDe) { if (!StringUtil.isEmpty(de.getPublicId()) && de.getPublicId().equals(newDataElement.getPublicId())) return de; } } // if(des != null && ocs != null) { // for(ObjectClass oc : ocs) //// Map<String, DataElement> deList = new HashMap<String, DataElement>(); // for(DataElement de : des) // if(newDataElement.getDataElementConcept().getObjectClass() == // de.getDataElementConcept().getObjectClass()) // if(newDataElement.getPublicId() == de.getPublicId()) // return false; // } return null; }
/** * Removes a {@link DataElement} at the specified index. After the element has been successfully * removed all {@link DataListener DataListeners} will be informed. * * @param index Index of the element which will be removed. All elements with an index > * <tt>index</tt> will be shifted. */ public void removeElementAt(int index) { DataElement element = (DataElement) _container.elementAt(index); element.setContainer(null); _container.removeElementAt(index); notifyListeners(DataEvent.createRemoveEvent(this, index, element)); }