Package org.eurekastreams.server.domain

Examples of org.eurekastreams.server.domain.AppData


        Map<String, String> currentAppDataValues;

        try
        {
            AppData currentAppData = mapper.findOrCreateByPersonAndGadgetDefinitionIds(applicationId, openSocialId);
            if (currentAppData != null)
            {
                currentAppDataValues = new HashMap<String, String>(currentAppData.getValues());

                Iterator<String> appDataValueKeysIterator = inRequest.getAppDataValueKeys().iterator();

                while (appDataValueKeysIterator.hasNext())
                {
                    final String appDataValueKey = appDataValueKeysIterator.next();
                    // This is an implementation of the OpenSocial Spec 5.3.12.2.11
                    if (appDataValueKey == "*")
                    {
                        // Remove all of the AppDataValues for this AppData Instance.
                        for (Entry<String, String> entry : currentAppDataValues.entrySet())
                        {
                            mapper.deleteAppDataValueByKey(currentAppData.getId(), entry.getKey());
                        }
                        break;
                    }
                    if (currentAppDataValues.containsKey(appDataValueKey))
                    {
                        mapper.deleteAppDataValueByKey(currentAppData.getId(), appDataValueKey);
                    }

                }
                mapper.flush();

View Full Code Here


    public AppData findOrCreateByPersonAndGadgetDefinitionIds(final long gadgetDefinitionId, final String personId)
    {
        String logMsg = "GadgetDefId#" + gadgetDefinitionId + ", open social id: " + personId;
        log.info("Looking for the AppData in the database for " + logMsg);

        AppData outputAppData = null;
        Query query = getEntityManager().createQuery(
                "from AppData a where a.person.openSocialId = "
                        + ":openSocialId and a.gadgetDefinition.id = :gadgetDefinitionId").setParameter("openSocialId",
                personId).setParameter("gadgetDefinitionId", gadgetDefinitionId);
        List<AppData> appDataList = query.getResultList();
        if (appDataList.size() > 0)
        {
            // found it
            log.info("Found the AppData in the database for " + logMsg);

            outputAppData = appDataList.get(0);
        }
        else
        {
            // didn't find it - create it
            log.info("Didn't find the AppData in the database for " + logMsg + " - building it");

            Query getPersonQuery = getEntityManager().createQuery("from Person p where p.openSocialId = :openSocialId")
                    .setParameter("openSocialId", personId);
            Query getGadgetDefQuery = getEntityManager().createQuery(
                    "from GadgetDefinition gd where gd.id = :gadgetDefinitionId").setParameter("gadgetDefinitionId",
                    gadgetDefinitionId);
            Person currentPerson = null;
            GadgetDefinition currentGadgetDefinition = null;

            List<Person> peopleList = getPersonQuery.getResultList();
            if (peopleList.size() > 0)
            {
                List<GadgetDefinition> gadgetDefList = getGadgetDefQuery.getResultList();
                if (gadgetDefList.size() > 0)
                {
                    log.info("Persisting AppData for " + logMsg);

                    currentPerson = peopleList.get(0);
                    currentGadgetDefinition = gadgetDefList.get(0);
                    outputAppData = new AppData(currentPerson, currentGadgetDefinition);
                    getEntityManager().persist(outputAppData);
                }
            }

        }
View Full Code Here

TOP

Related Classes of org.eurekastreams.server.domain.AppData

Copyright © 2018 www.massapicom. 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.