Examples of Entity


Examples of org.apache.james.mime4j.dom.Entity

            multipart.addBodyPart(bodyPart, 2 * i + 1);
        }

        // For no particular reason remove the second binary body part (now
        // at index four).
        Entity removed = multipart.removeBodyPart(4);

        // The removed body part no longer has a parent entity it belongs to so
        // it should be disposed of.
        removed.dispose();

        // Set some headers on the transformed message
        message.createMessageId(HOSTNAME);
        message.setSubject("Transformed message");
        message.setDate(new Date());
View Full Code Here

Examples of org.apache.james.mime4j.message.Entity

    public void setMode(final HttpMultipartMode mode) {
        this.mode = mode;
    }

    protected Charset getCharset() {
        Entity e = getParent();
        ContentTypeField cField = (ContentTypeField) e.getHeader().getField(
                Field.CONTENT_TYPE);
        Charset charset = null;
       
        switch (this.mode) {
        case STRICT:
View Full Code Here

Examples of org.apache.jetspeed.security.mapping.model.Entity

   
    public Entity loadEntity(Object providerContext)
    {
        DirContextOperations ctx = (DirContextOperations)((SearchResult)(providerContext)).getObject();
        String entityId = null;
        Entity entity = null;
        String dn = ctx.getNameInNamespace();
        Set<Attribute> attributes = new HashSet<Attribute>();
        Attributes attrs = ctx.getAttributes();
        for (AttributeDef attrDef : searchConfiguration.getEntityAttributeDefinitionsMap().values())
        {
            List<String> values = null;
            values = getStringAttributes(attrs, attrDef.getName(), attrDef.requiresDnDefaultValue());
            if (values != null)
            {
                Attribute a = new AttributeImpl(attrDef);
                if (attrDef.isMultiValue())
                {
                    // remove the dummy value for required fields when present.
                    if (attrDef.isRequired())
                    {
                        String defaultValue = attrDef.requiresDnDefaultValue() ? dn : attrDef.getRequiredDefaultValue();
                        values.remove(defaultValue);
                    }
                       
                    if (values.size() != 0)
                    {
                        a.setValues(values);
                    }
                       
                    else
                    {
                        attributes.add(a);
                    }                       
                }
                else
                {
                    String value = values.get(0);
                    if (attrDef.isEntityIdAttribute())
                    {
                        entityId = value;
                    }
                    a.setValue(value);
                }
                attributes.add(a);
            }
        }
        if (entityId == null)
        {
            DistinguishedName name = new DistinguishedName(dn);           
            LdapRdn rdn = name.getLdapRdn(name.size()-1);
            if (rdn.getKey().equals(searchConfiguration.getLdapIdAttribute()))
            {
                entityId = rdn.getValue();
            }
            else
            {
                // TODO: throw exception???
                return null;
            }
        }
        entity = internalCreateEntity(entityId, dn, attributes);
        entity.setLive(true);
        return entity;
    }
View Full Code Here

Examples of org.apache.openejb.jee.jpa.Entity

                // Bean already has a persistence-context-ref for cmp
                // which means it has a mapping, so skip this bean
                continue;
            }

            Entity entity = new Entity();

            // description: contains the name of the entity bean
            entity.setDescription(ejbModule.getModuleId() + "#" + bean.getEjbName());

            // name: the name of the entity in queries
            String entityName = bean.getAbstractSchemaName();
            entity.setName(entityName);

            // class: impl class name
            String cmpImplClassName = CmpUtil.getCmpImplClassName(bean.getAbstractSchemaName(), bean.getEjbClass());
            entity.setClazz(cmpImplClassName);

            // add the entity
            entityMappings.getEntity().add(entity);
            entitiesByName.put(bean.getEjbName(), entity);

            if (bean.getCmpVersion() == CmpVersion.CMP2) {
                mapClass2x(entity, bean, classLoader);
            } else {
                // map the cmp class, but if we are using a mapped super class, generate attribute-override instead of id and basic
                Collection<MappedSuperclass> mappedSuperclasses = mapClass1x(bean.getEjbClass(), entity, bean, classLoader);
                for (MappedSuperclass mappedSuperclass : mappedSuperclasses) {
                    mappedSuperclassByClass.put(mappedSuperclass.getClazz(), mappedSuperclass);
                }
            }

            // process queries
            for (Query query : bean.getQuery()) {
                NamedQuery namedQuery = new NamedQuery();
                QueryMethod queryMethod = query.getQueryMethod();

                // todo deployment id could change in one of the later conversions... use entity name instead, but we need to save it off
                StringBuilder name = new StringBuilder();
                name.append(entityName).append(".").append(queryMethod.getMethodName());
                if (queryMethod.getMethodParams() != null && !queryMethod.getMethodParams().getMethodParam().isEmpty()) {
                    name.append('(');
                    boolean first = true;
                    for (String methodParam : queryMethod.getMethodParams().getMethodParam()) {
                        if (!first) name.append(",");
                        name.append(methodParam);
                        first = false;
                    }
                    name.append(')');
                }
                namedQuery.setName(name.toString());

                namedQuery.setQuery(query.getEjbQl());
                entity.getNamedQuery().add(namedQuery);
            }
            // todo: there should be a common interface between ejb query object and openejb query object
            EjbDeployment ejbDeployment = openejbJar.getDeploymentsByEjbName().get(bean.getEjbName());
            if (ejbDeployment != null) {
                for (org.apache.openejb.jee.oejb3.Query query : ejbDeployment.getQuery()) {
                    NamedQuery namedQuery = new NamedQuery();
                    org.apache.openejb.jee.oejb3.QueryMethod queryMethod = query.getQueryMethod();

                    // todo deployment id could change in one of the later conversions... use entity name instead, but we need to save it off
                    StringBuilder name = new StringBuilder();
                    name.append(entityName).append(".").append(queryMethod.getMethodName());
                    if (queryMethod.getMethodParams() != null && !queryMethod.getMethodParams().getMethodParam().isEmpty()) {
                        name.append('(');
                        boolean first = true;
                        for (String methodParam : queryMethod.getMethodParams().getMethodParam()) {
                            if (!first) name.append(",");
                            name.append(methodParam);
                            first = false;
                        }
                        name.append(')');
                    }
                    namedQuery.setName(name.toString());

                    namedQuery.setQuery(query.getObjectQl());
                    entity.getNamedQuery().add(namedQuery);
                }
            }
        }
        entityMappings.getMappedSuperclass().addAll(mappedSuperclassByClass.values());

        Relationships relationships = ejbJar.getRelationships();
        if (relationships != null) {
            for (EjbRelation relation : relationships.getEjbRelation()) {
                List<EjbRelationshipRole> roles = relation.getEjbRelationshipRole();
                // if we don't have two roles, the relation is bad so we skip it
                if (roles.size() != 2) {
                    continue;
                }

                // get left entity
                EjbRelationshipRole leftRole = roles.get(0);
                RelationshipRoleSource leftRoleSource = leftRole.getRelationshipRoleSource();
                String leftEjbName = leftRoleSource == null ? null : leftRoleSource.getEjbName();
                Entity leftEntity = entitiesByName.get(leftEjbName);

                // get right entity
                EjbRelationshipRole rightRole = roles.get(1);
                RelationshipRoleSource rightRoleSource = rightRole.getRelationshipRoleSource();
                String rightEjbName = rightRoleSource == null ? null : rightRoleSource.getEjbName();
                Entity rightEntity = entitiesByName.get(rightEjbName);

                // neither left or right have a mapping which is fine
                if (leftEntity == null && rightEntity == null) {
                    continue;
                }
                // left not found?
                if (leftEntity == null) {
                    throw new OpenEJBException("Role source " + leftEjbName + " defined in relationship role " +
                            relation.getEjbRelationName() + "::" + leftRole.getEjbRelationshipRoleName() + " not found");
                }
                // right not found?
                if (rightEntity == null) {
                    throw new OpenEJBException("Role source " + rightEjbName + " defined in relationship role " +
                            relation.getEjbRelationName() + "::" + rightRole.getEjbRelationshipRoleName() + " not found");
                }

                String leftFieldName = null;
                boolean leftSynthetic = false;
                if (leftRole.getCmrField() != null) {
                    leftFieldName = leftRole.getCmrField().getCmrFieldName();
                } else {
                    leftFieldName = rightEntity.getName() + "_" + rightRole.getCmrField().getCmrFieldName();
                    leftSynthetic = true;
                }
                boolean leftIsOne = leftRole.getMultiplicity() == Multiplicity.ONE;

                String rightFieldName = null;
                boolean rightSynthetic = false;
                if (rightRole.getCmrField() != null) {
                    rightFieldName = rightRole.getCmrField().getCmrFieldName();
                } else {
                    rightFieldName = leftEntity.getName() + "_" + leftRole.getCmrField().getCmrFieldName();
                    rightSynthetic = true;
                }
                boolean rightIsOne = rightRole.getMultiplicity() == Multiplicity.ONE;

                if (leftIsOne && rightIsOne) {
                    //
                    // one-to-one
                    //

                    // left
                    OneToOne leftOneToOne = null;
                    leftOneToOne = new OneToOne();
                    leftOneToOne.setName(leftFieldName);
                    leftOneToOne.setSyntheticField(leftSynthetic);
                    setCascade(rightRole, leftOneToOne);
                    leftEntity.getAttributes().getOneToOne().add(leftOneToOne);

                    // right
                    OneToOne rightOneToOne = null;
                    rightOneToOne = new OneToOne();
                    rightOneToOne.setName(rightFieldName);
                    rightOneToOne.setSyntheticField(rightSynthetic);
                    rightOneToOne.setMappedBy(leftFieldName);
                    setCascade(leftRole, rightOneToOne);
                    rightEntity.getAttributes().getOneToOne().add(rightOneToOne);

                    // link
                    leftOneToOne.setRelatedField(rightOneToOne);
                    rightOneToOne.setRelatedField(leftOneToOne);
                } else if (leftIsOne && !rightIsOne) {
                    //
                    // one-to-many
                    //

                    // left
                    OneToMany leftOneToMany = null;
                    leftOneToMany = new OneToMany();
                    leftOneToMany.setName(leftFieldName);
                    leftOneToMany.setSyntheticField(leftSynthetic);
                    leftOneToMany.setMappedBy(rightFieldName);
                    setCascade(rightRole, leftOneToMany);
                    leftEntity.getAttributes().getOneToMany().add(leftOneToMany);

                    // right
                    ManyToOne rightManyToOne = null;
                    rightManyToOne = new ManyToOne();
                    rightManyToOne.setName(rightFieldName);
                    rightManyToOne.setSyntheticField(rightSynthetic);
                    setCascade(leftRole, rightManyToOne);
                    rightEntity.getAttributes().getManyToOne().add(rightManyToOne);

                    // link
                    leftOneToMany.setRelatedField(rightManyToOne);
                    rightManyToOne.setRelatedField(leftOneToMany);
                } else if (!leftIsOne && rightIsOne) {
                    //
                    // many-to-one
                    //

                    // left
                    ManyToOne leftManyToOne = null;
                    leftManyToOne = new ManyToOne();
                    leftManyToOne.setName(leftFieldName);
                    leftManyToOne.setSyntheticField(leftSynthetic);
                    setCascade(rightRole, leftManyToOne);
                    leftEntity.getAttributes().getManyToOne().add(leftManyToOne);

                    // right
                    OneToMany rightOneToMany = null;
                    rightOneToMany = new OneToMany();
                    rightOneToMany.setName(rightFieldName);
                    rightOneToMany.setSyntheticField(rightSynthetic);
                    rightOneToMany.setMappedBy(leftFieldName);
                    setCascade(leftRole, rightOneToMany);
                    rightEntity.getAttributes().getOneToMany().add(rightOneToMany);

                    // link
                    leftManyToOne.setRelatedField(rightOneToMany);
                    rightOneToMany.setRelatedField(leftManyToOne);
                } else if (!leftIsOne && !rightIsOne) {
                    //
                    // many-to-many
                    //

                    // left
                    ManyToMany leftManyToMany = null;
                    leftManyToMany = new ManyToMany();
                    leftManyToMany.setName(leftFieldName);
                    leftManyToMany.setSyntheticField(leftSynthetic);
                    setCascade(rightRole, leftManyToMany);
                    leftEntity.getAttributes().getManyToMany().add(leftManyToMany);

                    // right
                    ManyToMany rightManyToMany = null;
                    rightManyToMany = new ManyToMany();
                    rightManyToMany.setName(rightFieldName);
                    rightManyToMany.setSyntheticField(rightSynthetic);
                    rightManyToMany.setMappedBy(leftFieldName);
                    setCascade(leftRole, rightManyToMany);
                    rightEntity.getAttributes().getManyToMany().add(rightManyToMany);

                    // link
                    leftManyToMany.setRelatedField(rightManyToMany);
                    rightManyToMany.setRelatedField(leftManyToMany);
                }
View Full Code Here

Examples of org.apache.stanbol.enhancer.engines.entitylinking.Entity

        //add some terms to the searcher
        MGraph graph = new IndexedMGraph();
        UriRef uri = new UriRef("urn:test:PatrickMarshall");
        graph.add(new TripleImpl(uri, NAME, new PlainLiteralImpl("Patrick Marshall")));
        graph.add(new TripleImpl(uri, TYPE, OntologicalClasses.DBPEDIA_PERSON));
        searcher.addEntity(new Entity(uri, graph));
       
        uri = new UriRef("urn:test:Geologist");
        graph.add(new TripleImpl(uri, NAME, new PlainLiteralImpl("Geologist")));
        graph.add(new TripleImpl(uri, TYPE, new UriRef(NamespaceEnum.skos+"Concept")));
        graph.add(new TripleImpl(uri, REDIRECT, new UriRef("urn:test:redirect:Geologist")));
        searcher.addEntity(new Entity(uri, graph));
        //a redirect
        uri = new UriRef("urn:test:redirect:Geologist");
        graph.add(new TripleImpl(uri, NAME, new PlainLiteralImpl("Geologe (redirect)")));
        graph.add(new TripleImpl(uri, TYPE, new UriRef(NamespaceEnum.skos+"Concept")));
        searcher.addEntity(new Entity(uri, graph));

        uri = new UriRef("urn:test:NewZealand");
        graph.add(new TripleImpl(uri, NAME, new PlainLiteralImpl("New Zealand")));
        graph.add(new TripleImpl(uri, TYPE, OntologicalClasses.DBPEDIA_PLACE));
        searcher.addEntity(new Entity(uri, graph));

        uri = new UriRef("urn:test:UniversityOfOtago");
        graph.add(new TripleImpl(uri, NAME, new PlainLiteralImpl("University of Otago")));
        graph.add(new TripleImpl(uri, TYPE, OntologicalClasses.DBPEDIA_ORGANISATION));
        searcher.addEntity(new Entity(uri, graph));
       
        uri = new UriRef("urn:test:University");
        graph.add(new TripleImpl(uri, NAME, new PlainLiteralImpl("University")));
        graph.add(new TripleImpl(uri, TYPE, new UriRef(NamespaceEnum.skos+"Concept")));
        searcher.addEntity(new Entity(uri, graph));

        uri = new UriRef("urn:test:Otago");
        graph.add(new TripleImpl(uri, NAME, new PlainLiteralImpl("Otago")));
        graph.add(new TripleImpl(uri, TYPE, OntologicalClasses.DBPEDIA_PLACE));
        searcher.addEntity(new Entity(uri, graph));
        //add a 2nd Otago (Place and University
        uri = new UriRef("urn:test:Otago_Texas");
        graph.add(new TripleImpl(uri, NAME, new PlainLiteralImpl("Otago (Texas)")));
        graph.add(new TripleImpl(uri, NAME, new PlainLiteralImpl("Otago")));
        graph.add(new TripleImpl(uri, TYPE, OntologicalClasses.DBPEDIA_PLACE));
        searcher.addEntity(new Entity(uri, graph));

        uri = new UriRef("urn:test:UniversityOfOtago_Texas");
        graph.add(new TripleImpl(uri, NAME, new PlainLiteralImpl("University of Otago (Texas)")));
        graph.add(new TripleImpl(uri, TYPE, OntologicalClasses.DBPEDIA_ORGANISATION));
        searcher.addEntity(new Entity(uri, graph));
       
        TEST_ANALYSED_TEXT = AnalysedTextFactory.getDefaultInstance().createAnalysedText(
            ciFactory.createBlob(new StringSource(TEST_TEXT)));
        TEST_ANALYSED_TEXT_WO = AnalysedTextFactory.getDefaultInstance().createAnalysedText(
                ciFactory.createBlob(new StringSource(TEST_TEXT_WO)));
View Full Code Here

Examples of org.apache.stanbol.entityhub.servicesapi.model.Entity

                try {
                    // When using the Cache, directly get the representations!
                    QueryResultList<Representation> representations = cache.findRepresentation((query));
                    results = new ArrayList<Entity>(representations.size());
                    for (Representation result : representations) {
                        Entity entity = new EntityImpl(getId(), result, null);
                        results.add(entity);
                        initEntityMetadata(entity, siteMetadata,
                            singletonMap(RdfResourceEnum.isChached.getUri(), (Object) Boolean.TRUE));
                    }
                    return new QueryResultListImpl<Entity>(query, results, Entity.class);
                } catch (YardException e) {
                    if (siteConfiguration.getEntitySearcherType() == null || isOfflineMode()) {
                        throw new SiteException("Unable to execute query on Cache "
                                + siteConfiguration.getCacheId(), e);
                    } else {
                        log.warn(
                            String.format(
                                "Error while performing query on Cache %s! Try to use remote site %s as fallback!",
                                siteConfiguration.getCacheId(), siteConfiguration.getQueryUri()), e);
                    }
                }
            } else {
                if (siteConfiguration.getEntitySearcherType() == null || isOfflineMode()) {
                    throw new SiteException(String.format(
                        "Unable to execute query on Cache %s because it is currently not active",
                        siteConfiguration.getCacheId()));
                } else {
                    log.warn(String.format(
                        "Cache %s currently not active will query remote Site %s as fallback",
                        siteConfiguration.getCacheId(), siteConfiguration.getQueryUri()));
                }
            }
        }
        QueryResultList<String> entityIds;
        if (entitySearcher == null) {
            throw new SiteException(String.format("EntitySearcher %s not available for remote site %s!",
                siteConfiguration.getEntitySearcherType(), siteConfiguration.getQueryUri()));
        }
        ensureOnline(siteConfiguration.getQueryUri(), entitySearcher.getClass());
        try {
            log.trace("Will use an entity-searcher [type :: {}][query-uri :: {}].", entitySearcher.getClass()
                    .toString(), EntitySearcher.QUERY_URI);
            entityIds = entitySearcher.findEntities(query);
        } catch (IOException e) {
            throw new SiteException(String.format(
                "Unable to execute query on remote site %s with entitySearcher %s!",
                siteConfiguration.getQueryUri(), siteConfiguration.getEntitySearcherType()), e);
        }
        int numResults = entityIds.size();
        List<Entity> entities = new ArrayList<Entity>(numResults);
        int errors = 0;
        SiteException lastError = null;
        for (String id : entityIds) {
            Entity entity;
            try {
                entity = getEntity(id);
                if (entity == null) {
                    log.warn("Unable to create Entity for ID that was selected by an FieldQuery (id=" + id
                            + ")");
                }
                entities.add(entity);
                // use the position in the list as resultSocre
                entity.getRepresentation().set(RdfResourceEnum.resultScore.getUri(),
                    Float.valueOf((float) numResults));
            } catch (SiteException e) {
                lastError = e;
                errors++;
                log.warn(String
View Full Code Here

Examples of org.apache.tapestry5.integration.app1.data.Entity

                return value.getId();
            }

            public Entity toValue(String clientValue)
            {
                Entity entity = new Entity();
                entity.setId(clientValue);
                entity.setLabel("label" + clientValue);
                return entity;
            }
        };

        ValueEncoderFactory<Entity> valueEncoderFactory = new ValueEncoderFactory<Entity>()
View Full Code Here

Examples of org.apache.vysper.xmpp.addressing.Entity

        rosterManager = new MemoryRosterManager();
        OpenStorageProviderRegistry storageProviderRegistry = new OpenStorageProviderRegistry();
        storageProviderRegistry.add(rosterManager);
        ((DefaultServerRuntimeContext) sessionContext.getServerRuntimeContext()).setStorageProviderRegistry(storageProviderRegistry);

        Entity client = EntityImpl.parse("tester@vysper.org");
        sessionContext.setInitiatingEntity(client);
        initiatingUser = TestUser.createForSession(sessionContext, client);

        // set up more resources for the same session
        anotherInterestedNotAvailUser = TestUser.createForSession(sessionContext, client);
View Full Code Here

Examples of org.applause.lang.applauseDsl.Entity

  @org.jnario.runner.Extension
  public EntityDataMappingModuleFileCompiler _entityDataMappingModuleFileCompiler;
 
  private Entity entity(final CharSequence input, final String entityName) {
    try {
      Entity _xblockexpression = null;
      {
        final Model model = this._parseHelper.parse(input);
        EList<NamedElement> _elements = model.getElements();
        Iterable<Entity> _filter = Iterables.<Entity>filter(_elements, Entity.class);
        final Function1<Entity,Boolean> _function = new Function1<Entity,Boolean>() {
          public Boolean apply(final Entity it) {
            String _name = it.getName();
            boolean _equals = Objects.equal(_name, entityName);
            return Boolean.valueOf(_equals);
          }
        };
        Entity _findFirst = IterableExtensions.<Entity>findFirst(_filter, _function);
        _xblockexpression = (_findFirst);
      }
      return _xblockexpression;
    } catch (Throwable _e) {
      throw Exceptions.sneakyThrow(_e);
View Full Code Here

Examples of org.broadleafcommerce.openadmin.dto.Entity

               
                //re-initialize the valid properties for the entity in order to deal with the potential of not
                //completely sending over all checkbox/radio fields
                List<Serializable> entityList = new ArrayList<Serializable>(1);
                entityList.add(instance);
                Entity invalid = getRecords(mergedProperties, entityList, null, null)[0];
                invalid.setPropertyValidationErrors(entity.getPropertyValidationErrors());
                invalid.overridePropertyValues(entity);

                StringBuilder sb = new StringBuilder();
                for (Map.Entry<String, List<String>> entry : invalid.getPropertyValidationErrors().entrySet()) {
                    Iterator<String> itr = entry.getValue().iterator();
                    while(itr.hasNext()) {
                        sb.append(entry.getKey());
                        sb.append(" : ");
                        sb.append(itr.next());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.