com.google.web.bindery.autobean.shared.AutoBean Java Examples

The following examples show how to use com.google.web.bindery.autobean.shared.AutoBean. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Index.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void add(final String token, final Set<String> keywords, final String description) {
    long id = idCounter++;

    Document document = beanFactory.indexDocument().as();
    document.setId(id);
    document.setToken(token);
    document.setDescription(description);
    document.setKeywords(keywords);
    AutoBean<Document> autoBean = AutoBeanUtils.getAutoBean(document);
    String json = AutoBeanCodex.encode(autoBean).getPayload();
    localStorage.setItem(key(id), json);

    String keywordsValue = null;
    if (keywords != null && !keywords.isEmpty()) {
        StringBuilder builder = new StringBuilder();
        for (Iterator<String> iterator = keywords.iterator(); iterator.hasNext(); ) {
            String keyword = iterator.next();
            builder.append(keyword);
            if (iterator.hasNext()) {
                builder.append(" ");
            }
        }
        keywordsValue = builder.toString();
    }
    addInternal(String.valueOf(id), token, keywordsValue, description);
}
 
Example #2
Source File: Index.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public List<Document> search(final String text) {
    List<Document> results = new ArrayList<Document>();
    JsArray jsonResult = searchInternal(text);
    if (jsonResult != null) {
        for (int i = 0; i < jsonResult.length(); i++) {
            JSONObject json = new JSONObject(jsonResult.get(i));
            JSONString jsonId = json.get("ref").isString();
            if (jsonId != null) {
                long id = Long.parseLong(jsonId.stringValue());
                String documentJson = localStorage.getItem(key(id));
                if (documentJson != null) {
                    AutoBean<Document> autoBean = AutoBeanCodex.decode(beanFactory, Document.class, documentJson);
                    results.add(autoBean.as());
                }
            }
        }
    }
    return results;
}
 
Example #3
Source File: BootstrapServerStore.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public BootstrapServer restoreSelection() {
    if (storage != null) {
        //noinspection MismatchedQueryAndUpdateOfCollection
        StorageMap storageMap = new StorageMap(storage);
        if (storageMap.containsKey(KEY)) {
            String json = storageMap.get(SELECTED);
            if (json != null) {
                JSONValue jsonValue = JSONParser.parseStrict(json);
                if (jsonValue != null) {
                    JSONObject jsonObject = jsonValue.isObject();
                    if (jsonObject != null) {
                        AutoBean<BootstrapServer> bean = AutoBeanCodex
                                .decode(factory, BootstrapServer.class, jsonObject.toString());
                        return bean.as();
                    }
                }
            }
        }
    }
    return null;
}
 
Example #4
Source File: RBACAdapter.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static Set<String> getReadonlyAttributes(Object bean)
{
    final AutoBean autoBean = asAutoBean(bean);

    Set<String> atts = (Set<String>)autoBean.getTag(READ_ONLY_TAG);
    if(null==atts)
    {
        atts = new HashSet<String>();
        autoBean.setTag(READ_ONLY_TAG, atts);
    }

    return atts;
}
 
Example #5
Source File: AuditLogItemDataProvider.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private AuditLogItem parseItem(final MatchResult match) {
    String date = match.getGroup(1);
    AutoBean<AuditLogItem> itemBean = AutoBeanCodex.decode(beanFactory, AuditLogItem.class, match.getGroup(2));
    AuditLogItem item = itemBean.as();
    item.setId(idCounter++);
    item.setDate(date);
    return item;
}
 
Example #6
Source File: InterfaceManagementImpl.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public ValidationResult validateInterfaceConstraints(final Interface entity, Map<String, Object> changeset)
{

    //long s0 = System.currentTimeMillis();

    AutoBean<Interface> autoBean = AutoBeanUtils.getAutoBean(entity);
    Map<String, Object> properties = AutoBeanUtils.getAllProperties(autoBean);

    final List<String> decisions = new LinkedList<String>();

    DecisionTree.DecisionLog log = new DecisionTree.DecisionLog() {
        int index = 0;
        @Override
        public void append(String message) {
            index++;
            decisions.add("["+index+"] " + message);
        }
    };

    CompositeDecision decisionTree = new CompositeDecision();
    decisionTree.setLog(log);

    ValidationResult validation = decisionTree.validate(entity, changeset);

    // dump log
    StringBuilder sb = new StringBuilder();
    for(String s : decisions)
        sb.append(s).append(" \n");
    System.out.println(sb.toString());

    //System.out.println("** Exec time: "+(System.currentTimeMillis()-s0)+" ms **");
    return validation;
}
 
Example #7
Source File: BeanFactoryImpl.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public <T, U extends T> AutoBean<T> create(Class<T> clazz, U delegate) {
    throw new RuntimeException("not implemented");
}
 
Example #8
Source File: BeanFactoryImpl.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public AutoBean<Queue> queue() {
    throw new RuntimeException("not implemented");
}
 
Example #9
Source File: BeanFactoryImpl.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public AutoBean<XADataSource> xaDataSource() {
    throw new RuntimeException("not implemented");
}
 
Example #10
Source File: BeanFactoryImpl.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public AutoBean<Host> host() {
    return new AutoBeanStub<Host>(new HostImpl());
}
 
Example #11
Source File: BeanFactoryImpl.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public AutoBean<Jvm> jvm() {
    return new AutoBeanStub<Jvm>(new JvmImpl());
}
 
Example #12
Source File: BeanFactoryImpl.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public AutoBean<HeapMetric> heapMetric() {
    throw new RuntimeException("not implemented");
}
 
Example #13
Source File: BeanFactoryImpl.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public AutoBean<Server> server() {
    return new AutoBeanStub<Server>(new ServerImpl());
}
 
Example #14
Source File: SomeBeanCategory.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static String toString(AutoBean<SomeBean> instance) {
    return "Here comes SomeBean";
}
 
Example #15
Source File: BeanFactoryImpl.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public AutoBean<PropertyRecord> property() {
    return new AutoBeanStub<PropertyRecord>(new PropertyImpl());
}
 
Example #16
Source File: BeanFactoryImpl.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public AutoBean<SubsystemRecord> subsystem() {
    return new AutoBeanStub<SubsystemRecord>(new SubsystemImpl());
}
 
Example #17
Source File: AutoBeanStub.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public AutoBean<T> clone(boolean deep) {
    return null;  
}
 
Example #18
Source File: BeanFactoryImpl.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public AutoBean<ServerInstance> serverInstance() {
    return new AutoBeanStub<ServerInstance>(new ServerInstanceImpl());
}
 
Example #19
Source File: BeanFactoryImpl.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public AutoBean<RuntimeMetric> runtime(){
    throw new RuntimeException("not implemented");
}
 
Example #20
Source File: BeanFactoryImpl.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public AutoBean<HttpConnector> httpConnector() {
    throw new RuntimeException("not implemented");
}
 
Example #21
Source File: BeanFactoryImpl.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public AutoBean<CacheContainer> cacheContainer() {
    throw new RuntimeException("not implemented");
}
 
Example #22
Source File: BeanFactoryImpl.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public AutoBean<Interface> interfaceDeclaration() {
    throw new RuntimeException("not implemented");
}
 
Example #23
Source File: BeanFactoryImpl.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public AutoBean<LoggerConfig> loggerConfig() {
    throw new RuntimeException("not implemented");
}
 
Example #24
Source File: BeanFactoryImpl.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public AutoBean<StandaloneServer> standaloneServer() {
     throw new RuntimeException("not implemented");
}
 
Example #25
Source File: BeanFactoryImpl.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public AutoBean<WebServiceEndpoint> webServiceEndpoint() {
    throw new RuntimeException("not implemented");
}
 
Example #26
Source File: BeanFactoryImpl.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public AutoBean<ResourceAdapter> resourceAdapter() {
    throw new RuntimeException("not implemented");
}
 
Example #27
Source File: BeanFactoryImpl.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public AutoBean<Bundle> osgiBundle() {
    throw new RuntimeException("not implemented");
}
 
Example #28
Source File: BeanFactoryImpl.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public AutoBean<StrictMaxBeanPool> strictMaxBeanPool() {
    throw new RuntimeException("not implemented");
}
 
Example #29
Source File: BeanFactoryImpl.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public AutoBean<OSGiSubsystem> osgiSubsystem() {
    throw new RuntimeException("not implemented");
}
 
Example #30
Source File: BeanFactoryImpl.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public AutoBean<OSGiConfigAdminData> osgiConfigAdminData() {
    throw new RuntimeException("not implemented");
}