String constructDN(final T o, final String parentDN, final Map<String, Attribute> attrMap) throws LDAPPersistException { final String existingDN = getEntryDN(o); if (existingDN != null) { return existingDN; } final ArrayList<String> rdnNameList = new ArrayList<String>(1); final ArrayList<byte[]> rdnValueList = new ArrayList<byte[]>(1); for (final FieldInfo i : rdnFields) { final Attribute a = attrMap.get(toLowerCase(i.getAttributeName())); if (a == null) { throw new LDAPPersistException( ERR_OBJECT_HANDLER_RDN_FIELD_MISSING_VALUE.get(type.getName(), i.getField().getName())); } rdnNameList.add(a.getName()); rdnValueList.add(a.getValueByteArray()); } for (final GetterInfo i : rdnGetters) { final Attribute a = attrMap.get(toLowerCase(i.getAttributeName())); if (a == null) { throw new LDAPPersistException( ERR_OBJECT_HANDLER_RDN_GETTER_MISSING_VALUE.get( type.getName(), i.getMethod().getName())); } rdnNameList.add(a.getName()); rdnValueList.add(a.getValueByteArray()); } final String[] rdnNames = new String[rdnNameList.size()]; rdnNameList.toArray(rdnNames); final byte[][] rdnValues = new byte[rdnNames.length][]; rdnValueList.toArray(rdnValues); final RDN rdn = new RDN(rdnNames, rdnValues); if (parentDN == null) { return new DN(rdn, defaultParentDN).toString(); } else { try { final DN parsedParentDN = new DN(parentDN); return new DN(rdn, parsedParentDN).toString(); } catch (LDAPException le) { debugException(le); throw new LDAPPersistException( ERR_OBJECT_HANDLER_INVALID_PARENT_DN.get(type.getName(), parentDN, le.getMessage()), le); } } }
/** * This will invoke the <code>startElement</code> callback in the <code>ContentHandler</code>. * * @param element <code>Element</code> used in callbacks. * @param nsAtts <code>List</code> of namespaces to declare with the element or <code>null</code>. */ private void startElement(Element element, Attributes nsAtts) throws JDOMException { String namespaceURI = element.getNamespaceURI(); String localName = element.getName(); String rawName = element.getQualifiedName(); // Allocate attribute list. AttributesImpl atts = (nsAtts != null) ? new AttributesImpl(nsAtts) : new AttributesImpl(); List attributes = element.getAttributes(); Iterator i = attributes.iterator(); while (i.hasNext()) { Attribute a = (Attribute) i.next(); atts.addAttribute( a.getNamespaceURI(), a.getName(), a.getQualifiedName(), getAttributeTypeName(a.getAttributeType()), a.getValue()); } try { contentHandler.startElement(namespaceURI, localName, rawName, atts); } catch (SAXException se) { throw new JDOMException("Exception in startElement", se); } }
/* ------------------------------------------------------------ */ public AttributeList setAttributes(AttributeList attrs) { log.debug("setAttributes"); AttributeList results = new AttributeList(attrs.size()); Iterator iter = attrs.iterator(); while (iter.hasNext()) { try { Attribute attr = (Attribute) iter.next(); setAttribute(attr); results.add(new Attribute(attr.getName(), getAttribute(attr.getName()))); } catch (Exception e) { log.warn(LogSupport.EXCEPTION, e); } } return results; }
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]); } } }
/** Return index of attribute with same name and Namespace, or -1 if one doesn't exist */ private int indexOfDuplicate(Attribute attribute) { int duplicate = -1; String name = attribute.getName(); Namespace namespace = attribute.getNamespace(); duplicate = indexOf(name, namespace); return duplicate; }
/** Convert the attributes in the given XML Element into a Map of name/value pairs. */ protected static Map createAttributeMap(Element el) { Log.debug("Creating attribute map for " + el); Map attributes = new HashMap(); Iterator iter = el.getAttributes().iterator(); while (iter.hasNext()) { Attribute att = (Attribute) iter.next(); attributes.put(att.getName(), att.getValue()); } return attributes; }
/* ------------------------------------------------------------ */ public void setAttribute(Attribute attr) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { if (attr == null) return; if (log.isDebugEnabled()) log.debug("setAttribute " + attr.getName() + "=" + attr.getValue()); Method setter = (Method) _setter.get(attr.getName()); if (setter == null) throw new AttributeNotFoundException(attr.getName()); try { Object o = _object; if (setter.getDeclaringClass().isInstance(this)) o = this; setter.invoke(o, new Object[] {attr.getValue()}); } catch (IllegalAccessException e) { log.warn(LogSupport.EXCEPTION, e); throw new AttributeNotFoundException(e.toString()); } catch (InvocationTargetException e) { log.warn(LogSupport.EXCEPTION, e); throw new ReflectionException((Exception) e.getTargetException()); } }
public static List<Variant> getPossibleVariants( Product product, Variant variant, String selectedAttribute) { List<Variant> matchingVariantList = new ArrayList<Variant>(); List<Attribute> desiredAttributes = new ArrayList<Attribute>(); for (Attribute attribute : variant.getAttributes()) { if (!selectedAttribute.equals(attribute.getName()) && hasMoreAttributeValues(product, attribute.getName())) { desiredAttributes.add(attribute); } } VariantList variantList = product.getVariants().byAttributes(desiredAttributes); for (Attribute attr : product.getVariants().getAvailableAttributes(selectedAttribute)) { if (variantList.byAttributes(attr).size() < 1) { matchingVariantList.add((product.getVariants().byAttributes(attr).first()).orNull()); } else { matchingVariantList.add((variantList.byAttributes(attr).first()).orNull()); } } matchingVariantList.removeAll(Collections.singleton(null)); return matchingVariantList; }
private static boolean checkAttrs(String what, AttributeList attrs) { if (attrs.size() != 1) { System.out.println( "TEST FAILS: list returned by " + what + " does not have size 1: " + attrs); return false; } Attribute attr = (Attribute) attrs.get(0); if (!"Exotic".equals(attr.getName())) { System.out.println("TEST FAILS: " + what + " returned wrong " + "attribute: " + attr); return false; } return true; }
/** Return index of the <code>Attribute</code> with the given name and uri. */ int indexOf(String name, Namespace namespace) { String uri = namespace.getURI(); if (elementData != null) { for (int i = 0; i < size; i++) { Attribute old = elementData[i]; String oldURI = old.getNamespaceURI(); String oldName = old.getName(); if (oldURI.equals(uri) && oldName.equals(name)) { return i; } } } return -1; }
private static void renderPassThruAttributesOptimized( FacesContext context, ResponseWriter writer, UIComponent component, Attribute[] knownAttributes, List<String> setAttributes, Map<String, List<ClientBehavior>> behaviors) throws IOException { String behaviorEventName = getSingleBehaviorEventName(behaviors); boolean renderedBehavior = false; Collections.sort(setAttributes); boolean isXhtml = XHTML_CONTENT_TYPE.equals(writer.getContentType()); Map<String, Object> attrMap = component.getAttributes(); for (String name : setAttributes) { int index = Arrays.binarySearch(knownAttributes, Attribute.attr(name)); if (index >= 0) { Object value = attrMap.get(name); if (value != null && shouldRenderAttribute(value)) { Attribute attr = knownAttributes[index]; if (isBehaviorEventAttribute(attr, behaviorEventName)) { renderHandler(context, component, null, name, value, behaviorEventName); renderedBehavior = true; } else { writer.writeAttribute(prefixAttribute(name, isXhtml), value, name); } } } } if ((behaviorEventName != null) && !renderedBehavior) { for (int i = 0; i < knownAttributes.length; i++) { Attribute attr = knownAttributes[i]; String[] events = attr.getEvents(); if ((events != null) && (events.length > 0) && (behaviorEventName.equals(events[0]))) { renderHandler(context, component, null, attr.getName(), null, behaviorEventName); } } } }
private synchronized NameValueMap getCachedAttributes(ObjectName objName, Set<String> attrNames) throws InstanceNotFoundException, ReflectionException, IOException { NameValueMap values = cachedValues.get(objName); if (values != null && values.keySet().containsAll(attrNames)) { return values; } attrNames = new TreeSet<String>(attrNames); Set<String> oldNames = cachedNames.get(objName); if (oldNames != null) { attrNames.addAll(oldNames); } values = new NameValueMap(); final AttributeList attrs = conn.getAttributes(objName, attrNames.toArray(new String[attrNames.size()])); for (Attribute attr : attrs.asList()) { values.put(attr.getName(), attr.getValue()); } cachedValues.put(objName, values); cachedNames.put(objName, attrNames); return values; }
/** * Convert RichUsers to Identity objects with obfuscated email address and limited set of ext * sources. Service users are removed from the list. * * @param list RichUsers to convert * @return list of Identities without service ones * @throws PerunException */ private List<Identity> convertToIdentities(List<RichUser> list) throws PerunException { List<Identity> result = new ArrayList<Identity>(); if (list != null && !list.isEmpty()) { for (RichUser u : list) { // skip service users if (u.isServiceUser()) continue; Identity identity = new Identity(); identity.setName(u.getDisplayName()); identity.setId(u.getId()); for (Attribute a : u.getUserAttributes()) { if (MailManagerImpl.URN_USER_PREFERRED_MAIL.equals(a.getName())) { if (a.getValue() != null && !((String) a.getValue()).isEmpty()) { String safeMail = ((String) a.getValue()).split("@")[0]; if (safeMail.length() > 2) { safeMail = safeMail.substring(0, 1) + "****" + safeMail.substring(safeMail.length() - 1, safeMail.length()); } safeMail += "@" + ((String) a.getValue()).split("@")[1]; identity.setEmail(safeMail); } } else if ("urn:perun:user:attribute-def:def:organization".equals(a.getName())) { if (a.getValue() != null) { identity.setOrganization((String) a.getValue()); } } } List<ExtSource> es = new ArrayList<ExtSource>(); for (UserExtSource ues : u.getUserExtSources()) { if (ues.getExtSource().getType().equals(ExtSourcesManagerEntry.EXTSOURCE_X509)) { es.add(ues.getExtSource()); } else if (ues.getExtSource().getType().equals(ExtSourcesManagerEntry.EXTSOURCE_IDP)) { if (ues.getExtSource().getName().equals("https://extidp.cesnet.cz/idp/shibboleth")) { // FIXME - hack Social IdP to let us know proper identity source String type = ues.getLogin().split("@")[1].split("\\.")[0]; ues.getExtSource() .setName( "https://extidp.cesnet.cz/idp/shibboleth&authnContextClassRef=urn:cesnet:extidp:authn:" + type); } else if (ues.getExtSource().getName().equals("https://login.elixir-czech.org/idp/")) { // FIXME - hack Elixir proxy IdP to let us know proper identity source String type = ues.getLogin().split("@")[1]; ues.getExtSource().setName("https://login.elixir-czech.org/idp/@" + type); } es.add(ues.getExtSource()); } else if (ues.getExtSource() .getType() .equals(ExtSourcesManagerEntry.EXTSOURCE_KERBEROS)) { es.add(ues.getExtSource()); } } identity.setIdentities(es); result.add(identity); } } return result; }
private Filter createFilter(final T o, final AtomicBoolean addedRequiredOrAllowed) throws LDAPPersistException { final ArrayList<Attribute> attrs = new ArrayList<Attribute>(5); attrs.add(objectClassAttribute); for (final FieldInfo i : requiredFilterFields) { final Attribute a = i.encode(o, true); if (a == null) { throw new LDAPPersistException( ERR_OBJECT_HANDLER_FILTER_MISSING_REQUIRED_FIELD.get(i.getField().getName())); } else { attrs.add(a); addedRequiredOrAllowed.set(true); } } for (final GetterInfo i : requiredFilterGetters) { final Attribute a = i.encode(o); if (a == null) { throw new LDAPPersistException( ERR_OBJECT_HANDLER_FILTER_MISSING_REQUIRED_GETTER.get(i.getMethod().getName())); } else { attrs.add(a); addedRequiredOrAllowed.set(true); } } for (final FieldInfo i : alwaysAllowedFilterFields) { final Attribute a = i.encode(o, true); if (a != null) { attrs.add(a); addedRequiredOrAllowed.set(true); } } for (final GetterInfo i : alwaysAllowedFilterGetters) { final Attribute a = i.encode(o); if (a != null) { attrs.add(a); addedRequiredOrAllowed.set(true); } } for (final FieldInfo i : conditionallyAllowedFilterFields) { final Attribute a = i.encode(o, true); if (a != null) { attrs.add(a); } } for (final GetterInfo i : conditionallyAllowedFilterGetters) { final Attribute a = i.encode(o); if (a != null) { attrs.add(a); } } final ArrayList<Filter> comps = new ArrayList<Filter>(attrs.size()); for (final Attribute a : attrs) { for (final ASN1OctetString v : a.getRawValues()) { comps.add(Filter.createEqualityFilter(a.getName(), v.getValue())); } } if (superclassHandler != null) { final Filter f = superclassHandler.createFilter(o, addedRequiredOrAllowed); if (f.getFilterType() == Filter.FILTER_TYPE_AND) { comps.addAll(Arrays.asList(f.getComponents())); } else { comps.add(f); } } return Filter.createANDFilter(comps); }
public void startGroup(Group g) throws Hdf5Exception { logger.logComment("----- Going into a group: " + g.getFullName()); ArrayList<Attribute> attrs = Hdf5Utils.parseGroupForAttributes(g); for (Attribute attribute : attrs) { // attribute. logger.logComment( "Group: " + g.getName() + " has attribute: " + attribute.getName() + " = " + Hdf5Utils.getFirstStringValAttr(attrs, attribute.getName())); } if (g.getName().equals(NetworkMLConstants.ROOT_ELEMENT)) { logger.logComment("Found the main group"); String simConfigName = Hdf5Utils.getFirstStringValAttr(attrs, NetworkMLConstants.NC_SIM_CONFIG); if (simConfigName != null) this.foundSimConfig = simConfigName; String randomSeed = Hdf5Utils.getFirstStringValAttr(attrs, NetworkMLConstants.NC_NETWORK_GEN_RAND_SEED); if (randomSeed != null) this.foundRandomSeed = Long.parseLong(randomSeed); } else if (g.getName().equals(NetworkMLConstants.POPULATIONS_ELEMENT)) { logger.logComment("Found the pops group"); inPopulations = true; } else if (g.getName().startsWith(NetworkMLConstants.POPULATION_ELEMENT) && inPopulations) { String name = Hdf5Utils.getFirstStringValAttr(attrs, NetworkMLConstants.POP_NAME_ATTR); logger.logComment("Found a population: " + name); currentCellGroup = name; } else if (g.getName().equals(NetworkMLConstants.PROJECTIONS_ELEMENT)) { logger.logComment("Found the projections group"); inProjections = true; String units = Hdf5Utils.getFirstStringValAttr(attrs, NetworkMLConstants.UNITS_ATTR); projUnitSystem = UnitConverter.getUnitSystemIndex(units); } else if (g.getName().startsWith(NetworkMLConstants.PROJECTION_ELEMENT) && inProjections) { String name = Hdf5Utils.getFirstStringValAttr(attrs, NetworkMLConstants.PROJ_NAME_ATTR); String source = Hdf5Utils.getFirstStringValAttr(attrs, NetworkMLConstants.SOURCE_ATTR); String target = Hdf5Utils.getFirstStringValAttr(attrs, NetworkMLConstants.TARGET_ATTR); logger.logComment("Found a projection: " + name + " from " + source + " to " + target); if (!project.morphNetworkConnectionsInfo.isValidSimpleNetConn(name) && !project.volBasedConnsInfo.isValidVolBasedConn(name)) { throw new Hdf5Exception( "Error: there is a network connection with name: " + name + " specified in " + "that file, but no such NetConn exists in the project. Add one to allow import of this file"); } /* TODO: Add checks on source & target!! */ if (project.morphNetworkConnectionsInfo.isValidSimpleNetConn(name)) { // if (project.morphNetworkConnectionsInfo) } currentNetConn = name; } else if (g.getName().startsWith(NetworkMLConstants.SYN_PROPS_ELEMENT + "_") && inProjections) { String name = Hdf5Utils.getFirstStringValAttr(attrs, NetworkMLConstants.SYN_TYPE_ATTR); ConnSpecificProps cp = new ConnSpecificProps(name); String internalDelay = Hdf5Utils.getFirstStringValAttr(attrs, NetworkMLConstants.INTERNAL_DELAY_ATTR); if (internalDelay != null) cp.internalDelay = (float) UnitConverter.getTime( Float.parseFloat(internalDelay), projUnitSystem, UnitConverter.NEUROCONSTRUCT_UNITS); // Lump them in to the internal delay... String preDelay = Hdf5Utils.getFirstStringValAttr(attrs, NetworkMLConstants.PRE_DELAY_ATTR); if (preDelay != null) cp.internalDelay = cp.internalDelay + (float) UnitConverter.getTime( Float.parseFloat(preDelay), projUnitSystem, UnitConverter.NEUROCONSTRUCT_UNITS); String postDelay = Hdf5Utils.getFirstStringValAttr(attrs, NetworkMLConstants.POST_DELAY_ATTR); if (postDelay != null) cp.internalDelay = cp.internalDelay + (float) UnitConverter.getTime( Float.parseFloat(postDelay), projUnitSystem, UnitConverter.NEUROCONSTRUCT_UNITS); cp.weight = Float.parseFloat(Hdf5Utils.getFirstStringValAttr(attrs, NetworkMLConstants.WEIGHT_ATTR)); String propDelay = Hdf5Utils.getFirstStringValAttr(attrs, NetworkMLConstants.PROP_DELAY_ATTR); if (propDelay != null) globAPDelay = (float) UnitConverter.getTime( Float.parseFloat(propDelay), projUnitSystem, UnitConverter.NEUROCONSTRUCT_UNITS); logger.logComment("Found: " + cp); globConnProps.add(cp); } else if (g.getName().equals(NetworkMLConstants.INPUTS_ELEMENT)) { logger.logComment("Found the Inputs group"); inInputs = true; String units = Hdf5Utils.getFirstStringValAttr(attrs, NetworkMLConstants.UNITS_ATTR); inputUnitSystem = UnitConverter.getUnitSystemIndex(units); } else if (g.getName().startsWith(NetworkMLConstants.INPUT_ELEMENT) && inInputs) { // The table of input sites is within the input group so get sites from here String inputName = g.getName().substring(6); // String inputName = Hdf5Utils.getFirstStringValAttr(attrs, // NetworkMLConstants.INPUT_ELEMENT); logger.logComment("Found an Input: " + inputName); // inInput = true; if (project.elecInputInfo.getStim(inputName) == null) { throw new Hdf5Exception( "Error: there is an electrical input with name: " + inputName + " specified in " + "that file, but no such electrical input exists in the project. Add one to allow import of this file"); } // Get the atributes of the Input and compare them with the attributes within the project // Test to find out what type of input this is } else if (g.getName().startsWith("IClamp") && inInputs) { String inputName = g.getParent().getName().substring(6); // Get the input sites from the table String cellGroup = Hdf5Utils.getFirstStringValAttr(attrs, NetworkMLConstants.INPUT_TARGET_POPULATION_ATTR); if (cellGroup == null) { cellGroup = Hdf5Utils.getFirstStringValAttr( attrs, NetworkMLConstants.INPUT_TARGET_CELLGROUP_OLD_ATTR); // check old name } float readDelay = (float) UnitConverter.getTime( Float.parseFloat( Hdf5Utils.getFirstStringValAttr(attrs, NetworkMLConstants.INPUT_DELAY_ATTR)), inputUnitSystem, UnitConverter.NEUROCONSTRUCT_UNITS); float readDuration = (float) UnitConverter.getTime( Float.parseFloat( Hdf5Utils.getFirstStringValAttr(attrs, NetworkMLConstants.INPUT_DUR_ATTR)), inputUnitSystem, UnitConverter.NEUROCONSTRUCT_UNITS); float readAmp = (float) UnitConverter.getCurrent( Float.parseFloat( Hdf5Utils.getFirstStringValAttr(attrs, NetworkMLConstants.INPUT_AMP_ATTR)), inputUnitSystem, UnitConverter.NEUROCONSTRUCT_UNITS); StimulationSettings nextStim = project.elecInputInfo.getStim(inputName); ElectricalInput myElectricalInput = nextStim.getElectricalInput(); IClamp ic = (IClamp) myElectricalInput; logger.logComment("Found an IClamp Input"); float currDelay = -1, currDur = -1, currAmp = -1; /* try { ic.getDelay().reset(); currDelay = ic.getDelay().getNumber(); ic.getDuration().reset(); currDur = ic.getDuration().getNumber(); ic.getAmplitude().reset(); currAmp = ic.getAmplitude().getNumber(); } catch (Exception ex) { logger.logError("Legacy error getting iclamp params!!"); }*/ currDelay = ic.getDel().getNominalNumber(); currDur = ic.getDur().getNominalNumber(); currAmp = ic.getAmp().getNominalNumber(); if ((!project.elecInputInfo.getStim(inputName).getCellGroup().equals(cellGroup)) || (readDelay != currDelay) || (readDuration != currDur) || (readAmp != currAmp)) { throw new Hdf5Exception( "Error: the input properties of the file do not match those in the project for input " + inputName + "" + "\nreadDelay: " + readDelay + ", currDelay: " + currDelay + "\nreadDuration: " + readDuration + ", currDur: " + currDur + "\nreadAmp: " + readAmp + ", currAmp: " + currAmp + ", str: " + Hdf5Utils.getFirstStringValAttr(attrs, NetworkMLConstants.INPUT_AMP_ATTR)); } currentInput = inputName; } else if (g.getName().startsWith("RandomSpikeTrain") && inInputs) { String inputName = g.getParent().getName().substring(6); // Get the input sites from the table String cellGroup = Hdf5Utils.getFirstStringValAttr(attrs, NetworkMLConstants.INPUT_TARGET_POPULATION_ATTR); if (cellGroup == null) { cellGroup = Hdf5Utils.getFirstStringValAttr( attrs, NetworkMLConstants.INPUT_TARGET_CELLGROUP_OLD_ATTR); // check old name } float frequency = (float) UnitConverter.getRate( Float.parseFloat( Hdf5Utils.getFirstStringValAttr( attrs, NetworkMLConstants.RND_STIM_FREQ_ATTR)), inputUnitSystem, UnitConverter.NEUROCONSTRUCT_UNITS); String mechanism = Hdf5Utils.getFirstStringValAttr(attrs, NetworkMLConstants.RND_STIM_MECH_ATTR); StimulationSettings nextStim = project.elecInputInfo.getStim(inputName); ElectricalInput myElectricalInput = nextStim.getElectricalInput(); RandomSpikeTrain rs = (RandomSpikeTrain) myElectricalInput; logger.logComment("Found an Random Spike Train Input"); if ((!project.elecInputInfo.getStim(inputName).getCellGroup().equals(cellGroup)) || frequency != rs.getRate().getFixedNum() || !rs.getSynapseType().equals(mechanism)) { throw new Hdf5Exception( "Error: the input properties of the file do not match those in the project for input " + inputName); } currentInput = inputName; } }
public void dataSet(Dataset d) throws Hdf5Exception { logger.logComment("----- Looking through dataset: " + d); ArrayList<Attribute> attrs = Hdf5Utils.parseDatasetForAttributes(d); for (Attribute attribute : attrs) { logger.logComment( "Dataset: " + d.getName() + " has attribute: " + attribute.getName() + " = " + Hdf5Utils.getFirstStringValAttr(attrs, attribute.getName())); } float[][] data = Hdf5Utils.parse2Ddataset(d); logger.logComment("Data has size: (" + data.length + ", " + data[0].length + ")"); if (inPopulations && currentCellGroup != null) { for (int i = 0; i < data.length; i++) { int id = (int) data[i][0]; float x = data[i][1]; float y = data[i][2]; float z = data[i][3]; PositionRecord posRec = new PositionRecord(id, x, y, z); if (data[0].length == 5) { posRec.setNodeId((int) data[i][4]); } this.project.generatedCellPositions.addPosition(currentCellGroup, posRec); } } if (inProjections && currentNetConn != null) { logger.logComment("Adding info for NetConn: " + currentNetConn); int id_col = -1; int pre_cell_id_col = -1; int pre_segment_id_col = -1; int pre_fraction_along_col = -1; int post_cell_id_col = -1; int post_segment_id_col = -1; int post_fraction_along_col = -1; int prop_delay_col = -1; for (Attribute attribute : attrs) { String storedInColumn = Hdf5Utils.getFirstStringValAttr(attrs, attribute.getName()); if (storedInColumn.equals(NetworkMLConstants.CONNECTION_ID_ATTR)) { id_col = Integer.parseInt(attribute.getName().substring("column_".length())); logger.logComment("id col: " + id_col); } else if (storedInColumn.equals(NetworkMLConstants.PRE_CELL_ID_ATTR)) { pre_cell_id_col = Integer.parseInt(attribute.getName().substring("column_".length())); } else if (storedInColumn.equals(NetworkMLConstants.PRE_SEGMENT_ID_ATTR)) { pre_segment_id_col = Integer.parseInt(attribute.getName().substring("column_".length())); logger.logComment("pre_segment_id_col: " + pre_segment_id_col); } else if (storedInColumn.equals(NetworkMLConstants.PRE_FRACT_ALONG_ATTR)) { pre_fraction_along_col = Integer.parseInt(attribute.getName().substring("column_".length())); logger.logComment("pre_fraction_along_col: " + pre_fraction_along_col); } else if (storedInColumn.equals(NetworkMLConstants.POST_CELL_ID_ATTR)) { post_cell_id_col = Integer.parseInt(attribute.getName().substring("column_".length())); } else if (storedInColumn.equals(NetworkMLConstants.POST_SEGMENT_ID_ATTR)) { post_segment_id_col = Integer.parseInt(attribute.getName().substring("column_".length())); } else if (storedInColumn.equals(NetworkMLConstants.POST_FRACT_ALONG_ATTR)) { post_fraction_along_col = Integer.parseInt(attribute.getName().substring("column_".length())); } else if (storedInColumn.startsWith(NetworkMLConstants.PROP_DELAY_ATTR)) { prop_delay_col = Integer.parseInt(attribute.getName().substring("column_".length())); } for (String synType : getConnectionSynTypes()) { if (storedInColumn.endsWith(synType)) { ConnSpecificProps cp = null; for (ConnSpecificProps currCp : localConnProps) { if (currCp.synapseType.equals(synType)) cp = currCp; } if (cp == null) { cp = new ConnSpecificProps(synType); cp.internalDelay = -1; cp.weight = -1; localConnProps.add(cp); } if (storedInColumn.startsWith(NetworkMLConstants.INTERNAL_DELAY_ATTR)) { cp.internalDelay = Integer.parseInt( attribute .getName() .substring("column_".length())); // store the col num temporarily.. } if (storedInColumn.startsWith(NetworkMLConstants.WEIGHT_ATTR)) { cp.weight = Integer.parseInt( attribute .getName() .substring("column_".length())); // store the col num temporarily.. } } } } for (int i = 0; i < data.length; i++) { int pre_seg_id = 0; float pre_fract_along = 0.5f; int post_seg_id = 0; float post_fract_along = 0.5f; int id = (int) data[i][id_col]; int pre_cell_id = (int) data[i][pre_cell_id_col]; int post_cell_id = (int) data[i][post_cell_id_col]; float prop_delay = 0; if (pre_segment_id_col >= 0) pre_seg_id = (int) data[i][pre_segment_id_col]; if (pre_fraction_along_col >= 0) pre_fract_along = data[i][pre_fraction_along_col]; if (post_segment_id_col >= 0) post_seg_id = (int) data[i][post_segment_id_col]; if (post_fraction_along_col >= 0) post_fract_along = data[i][post_fraction_along_col]; // (float)UnitConverter.getTime(XXXXXXXXX, UnitConverter.NEUROCONSTRUCT_UNITS, // unitSystem)+""; if (prop_delay_col >= 0) prop_delay = (float) UnitConverter.getTime( data[i][prop_delay_col], projUnitSystem, UnitConverter.NEUROCONSTRUCT_UNITS); ArrayList<ConnSpecificProps> props = new ArrayList<ConnSpecificProps>(); if (localConnProps.size() > 0) { for (ConnSpecificProps currCp : localConnProps) { logger.logComment("Pre cp: " + currCp); ConnSpecificProps cp2 = new ConnSpecificProps(currCp.synapseType); if (currCp.internalDelay > 0) // index was stored in this val... cp2.internalDelay = (float) UnitConverter.getTime( data[i][(int) currCp.internalDelay], projUnitSystem, UnitConverter.NEUROCONSTRUCT_UNITS); if (currCp.weight > 0) // index was stored in this val... cp2.weight = data[i][(int) currCp.weight]; logger.logComment("Filled cp: " + cp2); props.add(cp2); } } this.project.generatedNetworkConnections.addSynapticConnection( currentNetConn, GeneratedNetworkConnections.MORPH_NETWORK_CONNECTION, pre_cell_id, pre_seg_id, pre_fract_along, post_cell_id, post_seg_id, post_fract_along, prop_delay, props); } } if (inInputs && currentInput != null) { logger.logComment("Adding info for: " + currentInput); StimulationSettings nextStim = project.elecInputInfo.getStim(currentInput); ElectricalInput myElectricalInput = nextStim.getElectricalInput(); String electricalInputType = myElectricalInput.getType(); String cellGroup = nextStim.getCellGroup(); for (int i = 0; i < data.length; i++) { Float fileCellId = data[i][0]; Float fileSegmentId = data[i][1]; Float fractionAlong = data[i][2]; int cellId = fileCellId.intValue(); int segmentId = fileSegmentId.intValue(); SingleElectricalInput singleElectricalInputFromFile = new SingleElectricalInput( electricalInputType, cellGroup, cellId, segmentId, fractionAlong, null); this.project.generatedElecInputs.addSingleInput( currentInput, singleElectricalInputFromFile); } } }
public String getName() { return att.getName(); }