コード例 #1
0
 public void testExtendingAliases() {
   CompassMapping compassMapping = ((InternalCompass) getCompass()).getMapping();
   AliasMapping aliasMapping = compassMapping.getAliasMapping("base");
   assertEquals(3, aliasMapping.getExtendingAliases().length);
   HashSet aliases = new HashSet();
   aliases.add("override");
   aliases.add("override1");
   aliases.add("extends");
   for (int i = 0; i < aliasMapping.getExtendingAliases().length; i++) {
     assertTrue(aliases.contains(aliasMapping.getExtendingAliases()[i]));
   }
 }
コード例 #2
0
 public Resource marshallIds(String alias, Object id) {
   ResourceMapping resourceMapping = mapping.getRootMappingByAlias(alias);
   if (resourceMapping == null) {
     return null;
   }
   return marshallIds(resourceMapping, id);
 }
コード例 #3
0
 public Resource marshallIds(Class clazz, Object id) {
   ResourceMapping resourceMapping = mapping.getRootMappingByClass(clazz);
   if (resourceMapping == null) {
     return null;
   }
   return marshallIds(resourceMapping, id);
 }
コード例 #4
0
 public Object unmarshall(Resource resource, MarshallingContext context) throws CompassException {
   ResourceMapping resourceMapping = mapping.getRootMappingByAlias(resource.getAlias());
   if (resourceMapping == null) {
     throw new MarshallingException(
         "No mapping is defined for alias [ " + resource.getAlias() + "]");
   }
   return resourceMapping.getConverter().unmarshall(resource, resourceMapping, context);
 }
コード例 #5
0
 public Resource marshall(String alias, Object root) {
   ResourceMapping resourceMapping = mapping.getRootMappingByAlias(alias);
   if (resourceMapping == null) {
     return null;
   }
   Resource resource = resourceFactory.createResource(alias);
   resourceMapping.getConverter().marshall(resource, root, resourceMapping, createContext());
   return resource;
 }
コード例 #6
0
 public Resource marshall(Object root) {
   if (root instanceof AliasedObject) {
     return marshall(((AliasedObject) root).getAlias(), root);
   }
   ResourceMapping resourceMapping = mapping.getRootMappingByClass(root.getClass());
   if (resourceMapping == null) {
     return null;
   }
   Resource resource = resourceFactory.createResource(resourceMapping.getAlias());
   resourceMapping.getConverter().marshall(resource, root, resourceMapping, createContext());
   return resource;
 }
  public CompassMapping process(
      CompassMapping compassMapping,
      PropertyNamingStrategy namingStrategy,
      ConverterLookup converterLookup,
      CompassSettings settings)
      throws MappingException {

    globalNullValue = settings.getSetting(CompassEnvironment.NullValue.NULL_VALUE);

    for (Iterator rIt = compassMapping.mappingsIt(); rIt.hasNext(); ) {
      Mapping mapping = (Mapping) rIt.next();
      processMapping(mapping);
    }
    return compassMapping;
  }
コード例 #8
0
 public void marshallIds(Object root, Object id) {
   ResourceMapping resourceMapping = mapping.getMappingByClass(root.getClass());
   if (resourceMapping == null) {
     throw new MarshallingException(
         "No resource mapping is defined for class [" + root.getClass() + "]");
   }
   Mapping[] ids = resourceMapping.getIdMappings();
   if (ids == null || ids.length == 0) {
     return;
   }
   Object[] idsValues = unmarshallIds(resourceMapping, id, createContext());
   for (int i = 0; i < idsValues.length; i++) {
     setId(root, idsValues[i], (ObjectMapping) ids[i]);
   }
 }
コード例 #9
0
ファイル: AllTermsCache.java プロジェクト: adityavs/compass
 public AllTermsCache(CompassSettings settings, CompassMapping mapping) {
   for (ResourceMapping resourceMapping : mapping.getRootMappings()) {
     if (resourceMapping.getAllMapping().isExcludeAlias()) {
       aliasTokensPerRootAlias.put(resourceMapping.getAlias(), new Token[0]);
     } else {
       List<Token> aliasTokens = new ArrayList<Token>();
       aliasTokens.add(
           new Token(
               resourceMapping.getAlias().toLowerCase(), 0, resourceMapping.getAlias().length()));
       for (String extendedAlias : resourceMapping.getExtendedAliases()) {
         aliasTokens.add(new Token(extendedAlias.toLowerCase(), 0, extendedAlias.length()));
       }
       aliasTokensPerRootAlias.put(
           resourceMapping.getAlias(), aliasTokens.toArray(new Token[aliasTokens.size()]));
     }
   }
 }
コード例 #10
0
 public Object[] unmarshallIds(Class clazz, Object id) {
   ResourceMapping resourceMapping = mapping.findRootMappingByClass(clazz);
   return unmarshallIds(resourceMapping, id, createContext());
 }
コード例 #11
0
 public Object[] unmarshallIds(String alias, Object id) {
   ResourceMapping resourceMapping = mapping.getRootMappingByAlias(alias);
   return unmarshallIds(resourceMapping, id, createContext());
 }