public String extract(CatalogObjectPart<String> part) { try { String nList = (String)xpath.evaluate("/aal:user/aal:login/text()", new InputSource(new StringReader(part.getData())), XPathConstants.STRING); return nList; } catch (XPathExpressionException e) { log.error("Error processing user data!",e); } return null; }
@Override public CatalogObjectPart<String> mapRow(ResultSet rs, int rowNum) throws SQLException { return new CatalogObjectPart<String>( rs.getString(PART_TYPE), rs.getString(PART_DATA)); } };
mav.addObject("source", part.getData()); mav.addObject("mimetype", part.getType()); mav.addObject("timestamp", part.getTimestamp().toString());
protected Object[] readElement(final String extId) throws YaddaException { try { final CatalogObjectPart<String> part = catalogFacade.getPart(new YaddaObjectID(extId), CatalogParamConstants.TYPE_BWMETA1, null); final CatalogObjectPart<String> childrenPart = catalogFacade.getPart(new YaddaObjectID(extId), CatalogParamConstants.TYPE_ELEMENT_CHILDREN3, null); // final ElementTreeNode part = (ElementTreeNode) getPart(); // if (part != null && part instanceof ElementTreeNode) { // for (final Set<ElementTreeNode> childrenOfHierarchy : // part.getChildren().values()) { // children.addAll(childrenOfHierarchy); // } // } boolean hasChildren = false; if (childrenPart != null && childrenPart.getData() != null) { final ElementTreeNode childrenPartData = (ElementTreeNode) serializers.get( CatalogParamConstants.TYPE_ELEMENT_CHILDREN3).toObject(extId, childrenPart.getData()); hasChildren = hasChildren(childrenPartData); } if (part != null) { return new Object[] { (Element) serializers.get(CatalogParamConstants.TYPE_BWMETA1).toObject(extId, part.getData()), part.getTimestamp(), hasChildren }; } else { return null; } } catch (final Exception ex) { throw new YaddaException(ex); } }
private void recreatePartTypes() { List<String> partTypes = new ArrayList<String>(); for (CatalogObjectPart part: parts){ partTypes.add(part.getType()); } this.partTypes = partTypes.toArray(new String[partTypes.size()]); } }
CatalogObjectPart<String> part= cmo.getPart(type); if(part!=null) { String xml=part.getData(); parts.put(type, xml); if(xml!=null && type.equals(TYPE_BWMETA1)) { timestamp = part.getTimestamp(); statusTimestamp = part.getTimestamp();
/** * Returns the part of the object which has the specified type. * * @param type type of the part to return * @return the part found, null if the object does not have a part with this type */ public CatalogObjectPart<T> getPart(String type) { for (CatalogObjectPart<T> part : getParts()) if (part.getType().equals(type)) return part; return null; }
public static void storeYElements(File fout, List<YElement> lye) throws FileNotFoundException, UnsupportedEncodingException, TransformationException, IOException { FileOutputStream fos = new FileOutputStream(fout); OutputStreamWriter out = new OutputStreamWriter(fos, "UTF-8"); for (CatalogObject<String> co : o3.process(lye, null)) { for (CatalogObjectPart<String> cop : co.getParts()) { out.write(cop.getData()); out.flush(); } } out.close(); fos.close(); }
@Override public EnrichedPayload<YElement>[] process(CatalogObject<String> input, ProcessContext ctx) { for (CatalogObjectPart<String> part : input.getParts()) { if (part.getType().equals(CatalogParamConstants.TYPE_BWMETA2)) { log.info("data: \n {}", part.getData()); } } return super.process(input, ctx); } }
public CatalogObjectPart<String> mapRow(ResultSet rs, int rowNum) throws SQLException { return new CatalogObjectPart<String>( rs.getString(PART_TYPE), new Date(rs.getTimestamp(PART_STAMP).getTime()), rs.getString(PART_DATA)); } };
/** * Uses a configured extractor to find the value of the search_key field * for a catalog data part and returns it. * * @param part the catalog part to extract data from * @return the field to store in the database */ Map<String, Object> extractExtraField(CatalogObjectPart<String> part) { String value = null; PartKeyExtractor e = extractors.get(part.getType()); if (e != null) value = e.extract(part); return Collections.<String,Object>singletonMap(PART_SEARCH_KEY, value); }
private static void createOutputFile(NlmYToCatObjProcessingNode y2catObj, File oF, List<YElement> yel) throws TransformationException, UnsupportedEncodingException, FileNotFoundException, IOException { Collection<CatalogObject<String>> cos; cos = y2catObj.process(yel, null); int j = 0; for(CatalogObject<String> co : cos){ j++; if(j%6!=0) continue; OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(oF+"_"+(j/6-1)+".xml"),"UTF-8"); for(CatalogObjectPart<String> cop : co.getParts()){ out.write(cop.getData()); out.flush(); } out.close(); } }
/** * Updates a data part with a specified foreign key and a specific type. * * @param fk the foreign key (metadata pk) for the part * @param part the part to update */ protected void updatePart(long fk, CatalogObjectPart<String> part) throws DataAccessException { Map<String, Object> extra = extraFieldsForPartUpdate(part); String query = "UPDATE "+tablePrefix+PARTS_TABLE_NAME+" SET "+PART_DATA+"=?"; Object[] params = new Object[3+extra.size()]; params[0] = part.getData(); int n = 1; for (Entry<String, Object> e : extra.entrySet()) { query += ","+e.getKey()+"=?"; params[n] = e.getValue(); n+=1; } String where = " WHERE "+PART_FK+"=? AND "+PART_TYPE+"=?"; params[params.length-2] = fk; params[params.length-1] = part.getType(); jdbc.update(query+where, params); }
public CatalogObjectPart<String> mapRow(ResultSet rs, int rowNum) throws SQLException { return new CatalogObjectPart<String>( rs.getString(PART_TYPE), new Date(rs.getTimestamp(PART_STAMP).getTime()), rs.getString(PART_DATA)); } };
private CatalogObjectPart<String> findPreferedPart(Set<CatalogObjectPart<String>> parts) { String[] partPreferences = preparePartPreferences(); if (partPreferences == null || partPreferences.length == 0) { logger.warn("Prefered parts not defined. First one will be used."); Iterator<CatalogObjectPart<String>> iterator = parts.iterator(); if (iterator.hasNext()) { return iterator.next(); } else { return null; } } for (String partName : partPreferences) { for (CatalogObjectPart<String> candidatePart : parts) { String candidateName = pathPrefix + candidatePart.getType(); if (candidateName.equals(partName)) { return candidatePart; } } } return null; }
public void showElementPart(String id, String partType) { try { CatalogObjectPart<String> part = catalogFacade.getPart(new YaddaObjectID(id), partType, null); if (part == null) { os.println("Part doesn't exist"); } else { os.println(part.getData()); } } catch (CatalogException e) { e.printStackTrace(os); } }
@Override public BatchResult batch(final Collection<EditorOperation> operations, final EXECUTION_MODE mode) throws EditorException { for (final EditorOperation oper:operations) { if (oper instanceof SaveOperation) { final SaveOperation<String> op=(SaveOperation<String>) oper; for (final CatalogObjectPart<String> pa:op.getObject().getParts()){ if (pa.getType().equalsIgnoreCase(partType)) { try { queue.put(pa.getData()); } catch (final InterruptedException ex) { LoggerFactory.getLogger(FakeFacadesBeingIterator.class).error("Exception caught", ex); } } } } } return new BatchResult(null, new ArrayList<CatalogObjectMeta>()); }
public CatalogObjectPart<String> mapRow(ResultSet rs, int rowNum) throws SQLException { return new CatalogObjectPart<String>( rs.getString(PART_TYPE), new Date(rs.getTimestamp(PART_STAMP).getTime()), rs.getString(PART_DATA)); } };
/** * Removes from a catalog object all parts with ttransient types. * * @param co the object to modify */ private void removeTransientParts(CatalogObject<String> co) { Set<CatalogObjectPart<String>> pts = co.getParts(); Iterator<CatalogObjectPart<String>> it = pts.iterator(); while (it.hasNext()) { CatalogObjectPart<String> pt = it.next(); PartType t = curdao.knownType(pt.getType()); if (isTransient(t)) it.remove(); } }