コード例 #1
0
  public static Collection<IMedia> findReferencedMedia()
      throws MapperException, XPathExpressionException, SQLException {
    Set<IMedia> referenced = new HashSet<IMedia>();

    //		// TODO: obviously maintaining this list is not the way to go
    //		// I would like to have it so the structure clearly differentiates between an ID declaration
    // and
    //		// a reference to an object's id
    //		// something along the lines of <Snu><mainMedia><refId>1</refId></mainMedia></Snu>
    for (String ELEMENT : MapperHelper.REFERENCING_ELEMENTS) {
      NodeList elements = DataRegistry.getDocument().getElementsByTagName(ELEMENT);
      int length = elements.getLength();
      for (int i = 0; i < length; ++i) {
        Element element = (Element) elements.item(i);
        long refId = Long.parseLong(element.getTextContent());
        try {
          IResource resource = ResourceInputMapper.map(refId);
          if (resource instanceof IMedia) referenced.add((IMedia) resource);
        } catch (DomainObjectNotFoundException e) {
          e = null;
        }
      }
    }
    return referenced;
  }
コード例 #2
0
 public static <M extends IMedia> M map(long id, Class<M> clazz) throws MapperException {
   IResource resource = ResourceInputMapper.map(id);
   if (!clazz.isAssignableFrom(resource.getClass()))
     throw new MapperException(
         "expected: "
             + clazz.getCanonicalName()
             + " but found: "
             + resource.getClass().getCanonicalName());
   return clazz.cast(resource);
 }
コード例 #3
0
 public static IMedia map(long id) throws MapperException {
   IResource resource = ResourceInputMapper.map(id);
   return (IMedia) resource;
 }