Package org.apache.isis.core.metamodel.facets.object.encodeable

Examples of org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet


    private final OneToOneAssociation value;
    private final ObjectAdapter object;
    private final String oldValue;

    public SetValueCommand(final ObjectAdapter object, final OneToOneAssociation value) {
        final EncodableFacet facet = value.getFacet(EncodableFacet.class);
        this.oldValue = facet.toEncodedString(object);
        this.object = object;
        this.value = value;

        this.description = "reset the value to " + oldValue;
    }
View Full Code Here


        return description;
    }

    @Override
    public void undo() {
        final EncodableFacet facet = value.getFacet(EncodableFacet.class);
        final Object obj = facet.fromEncodedString(oldValue);
        final ObjectAdapter adapter = getAdapterManager().adapterFor(obj);
        value.setAssociation(object, adapter);
        // have commented this out because it isn't needed; the transaction manager will do this
        // for us on endTransaction. Still, if I'm wrong and it is needed, hopefully this
        // comment will help...
View Full Code Here

        system.addSpecification(new MovieSpecification());
        system.addSpecification(new PersonSpecification());

        system.getSpecification(String.class).setupIsEncodeable();
        system.getSpecification(String.class).addFacet(new EncodableFacet() {

            @Override
            public String toEncodedString(final ObjectAdapter object) {
                return object.getObject().toString();
            }
View Full Code Here

                    isisMetaModel.setAttributesForValue(xmlValueElement, valueNos.getShortIdentifier());

                    // return parsed string, else encoded string, else title.
                    String valueStr;
                    ParseableFacet parseableFacet = fieldNos.getFacet(ParseableFacet.class);
                    EncodableFacet encodeableFacet = fieldNos.getFacet(EncodableFacet.class);
                    if(parseableFacet != null) {
                      valueStr = parseableFacet.parseableTitle(value);
                    } else if(encodeableFacet != null) {
                      valueStr = encodeableFacet.toEncodedString(value);
                    } else {
                      valueStr = value.titleString();
                    }
                   
          final boolean notEmpty = (valueStr.length() > 0);
View Full Code Here

        // Root object specification
        final ObjectSpecification rootSpecification = mockery.mock(ObjectSpecification.class);
        final OneToOneAssociation nameField = mockery.mock(OneToOneAssociation.class);
        final ObjectSpecification nameSpecification = mockery.mock(ObjectSpecification.class, "name specification");
        final EncodableFacet encodeableFacet = mockery.mock(EncodableFacet.class);

        mockery.checking(new Expectations() {
            {
                atLeast(1).of(rootSpecification).isCollection();
                will(returnValue(false));
View Full Code Here

        if(valueAdapter == null) {
            return null;
        }
        ValueFacet valueFacet = getMemberSpecFacet(ValueFacet.class);
        if(valueFacet != null) {
            EncodableFacet encodableFacet = getMemberSpecFacet(EncodableFacet.class);
            return encodableFacet.toEncodedString(valueAdapter);
        }
        TitleFacet titleFacet = getMemberSpecFacet(TitleFacet.class);
        String title = titleFacet.title(valueAdapter, getLocalization());
        return LinkRepBuilder.newBuilder(repContext, "value", urlForObject()).withTitle(title).build();
    }
View Full Code Here

        final String fieldData = reader.readField(association.getId());
        if (fieldData != null) {
            if (fieldData.equals("null")) {
                association.initAssociation(object, null);
            } else {
                final EncodableFacet encodeableFacet = association.getSpecification().getFacet(EncodableFacet.class);
                String decryptedData = dataEncrypter.decrypt(fieldData);
                final ObjectAdapter value = encodeableFacet.fromEncodedString(decryptedData);
                association.initAssociation(object, value);
            }
        }
    }
View Full Code Here

    private void writeValue(final StateWriter writer, final ObjectAssociation association, final ObjectAdapter value) {
        String data;
        if (value == null) {
            data = null;
        } else {
            final EncodableFacet encodeableFacet = value.getSpecification().getFacet(EncodableFacet.class);
            data = encodeableFacet.toEncodedString(value);
            data  = dataEncrypter.encrypt(data);
        }
        writer.writeField(association.getId(), data);
    }
View Full Code Here

            final ObjectAdapter fieldValue = association.get(object);
            final String fieldName = association.getId();
            if (fieldValue == null) {
                data.put(fieldName, (Object) null);
            } else if (association.getSpecification().isEncodeable()) {
                final EncodableFacet encodeableFacet = fieldValue.getSpecification().getFacet(EncodableFacet.class);
                data.put(fieldName, encodeableFacet.toEncodedString(fieldValue));
            } else if (association instanceof OneToManyAssociation) {
                final List<JSONObject> collection = new ArrayList<JSONObject>();
                final CollectionFacet facet = fieldValue.getSpecification().getFacet(CollectionFacet.class);
                for (final ObjectAdapter element : facet.iterable(fieldValue)) {
                    collection.add(encodeTransientData(element, savedObject));
View Full Code Here

            if (association.getSpecification().isEncodeable()) {
                if (fieldValue == null) {
                    ((OneToOneAssociation) association).initAssociation(object, null);
                } else {
                    final EncodableFacet encodeableFacet =
                        association.getSpecification().getFacet(EncodableFacet.class);
                    final ObjectAdapter fromEncodedString = encodeableFacet.fromEncodedString((String) fieldValue);
                    ((OneToOneAssociation) association).initAssociation(object, fromEncodedString);
                }
            } else if (association instanceof OneToManyAssociation) {
                final JSONArray collection = (JSONArray) fieldValue;
                for (int i = 0; i < collection.length(); i++) {
View Full Code Here

TOP

Related Classes of org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet

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.