<commit_before>/**
 * [DEFINE YOUR PROJECT NAME/MODULE HERE]
 * [DEFINE YOUR PROJECT DESCRIPTION HERE] 
 * Copyright (C) 08/12/14 echinopsii
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package net.echinopsii.ariane.community.plugin.rabbitmq.injector.cache;

import net.echinopsii.ariane.community.core.injector.base.model.AbstractComponent;
import net.echinopsii.ariane.community.plugin.rabbitmq.directory.model.RabbitmqNode;
import net.echinopsii.ariane.community.plugin.rabbitmq.injector.RabbitmqInjectorBootstrap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;
import java.util.HashMap;

public class RabbitmqCachedComponent extends AbstractComponent implements Serializable {

    private static final long serialVersionUID = 1L;

    private static final Logger log = LoggerFactory.getLogger(RabbitmqCachedComponent.class);


    /*
     * TibcorvCachedComponent cache part implementation
     */
    private Long componentDirectoryID;
    private String componentId;
    private String componentName;
    private String componentURL;
    private transient HashMap<String,Object> componentProperties;

    public RabbitmqCachedComponent setRabbitmqComponentFields(RabbitmqNode tibcorvComponent) {
        this.componentDirectoryID = tibcorvComponent.getId();
        this.componentId = RabbitmqInjectorBootstrap.INJ_TREE_ROOT_PATH+"_"+tibcorvComponent.getName()+"_";
        this.componentName = tibcorvComponent.getName();
        this.componentURL = tibcorvComponent.getUrl();
        this.componentProperties = tibcorvComponent.getProperties();
        return this;
    }

    @Override
    public String  getComponentId() {
        return componentId;
    }

    @Override
    public String getComponentName() {
        return componentName;
    }

    public String getComponentURL() {
        return componentURL;
    }

    public HashMap<String, Object> getComponentProperties() {
        return componentProperties;
    }


    @Override
    public String getComponentType() {
        return null;
    }

    @Override
    public void refresh() {

    }

    @Override
    public void refreshAndMap() {

    }
}<commit_msg>[TAC-178] begin component gear refresh impl<commit_after>/**
 * [DEFINE YOUR PROJECT NAME/MODULE HERE]
 * [DEFINE YOUR PROJECT DESCRIPTION HERE] 
 * Copyright (C) 08/12/14 echinopsii
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package net.echinopsii.ariane.community.plugin.rabbitmq.injector.cache;

import net.echinopsii.ariane.community.core.injector.base.model.AbstractComponent;
import net.echinopsii.ariane.community.core.injector.base.model.Component;
import net.echinopsii.ariane.community.plugin.rabbitmq.directory.model.RabbitmqCluster;
import net.echinopsii.ariane.community.plugin.rabbitmq.directory.model.RabbitmqNode;
import net.echinopsii.ariane.community.plugin.rabbitmq.injector.RabbitmqInjectorBootstrap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;

public class RabbitmqCachedComponent extends AbstractComponent implements Serializable {

    private static final long serialVersionUID = 1L;

    private static final Logger log = LoggerFactory.getLogger(RabbitmqCachedComponent.class);


    /*
     * RabbitmqCachedComponent cache part implementation
     */
    private Long componentDirectoryID;
    private String componentId;
    private String componentName;
    private String componentURL;
    private transient HashMap<String,Object> componentProperties;
    private transient RabbitmqNode rabbitmqNode;

    public RabbitmqCachedComponent setRabbitmqComponentFields(RabbitmqNode rabbitmqComponent) {
        this.componentDirectoryID = rabbitmqComponent.getId();
        this.componentId = RabbitmqInjectorBootstrap.INJ_TREE_ROOT_PATH+"_"+rabbitmqComponent.getName()+"_";
        this.componentName = rabbitmqComponent.getName();
        this.componentURL = rabbitmqComponent.getUrl();
        this.componentProperties = rabbitmqComponent.getProperties();
        this.rabbitmqNode = rabbitmqComponent;
        return this;
    }

    @Override
    public String  getComponentId() {
        return componentId;
    }

    @Override
    public String getComponentName() {
        return componentName;
    }

    public String getComponentURL() {
        return componentURL;
    }

    public HashMap<String, Object> getComponentProperties() {
        return componentProperties;
    }


    @Override
    public String getComponentType() {
        return "RabbitMQ Server";
    }

    @Override
    public void refresh() {
        super.setRefreshing(true);
        log.debug("Refresh component : " + this.componentURL);
        this.rabbitmqNode = RabbitmqInjectorBootstrap.getRabbitmqDirectorySce().refreshRabbitmqNode(this.rabbitmqNode);
        if (this.rabbitmqNode!=null) {
            setRabbitmqComponentFields(this.rabbitmqNode);
            super.setNextAction(Component.ACTION_CREATE);
        } else {
            super.setNextAction(Component.ACTION_DELETE);
        }
        log.debug("nextAction for {} : {}", componentName, super.getNextAction());

        RabbitmqCluster nodeCluster = RabbitmqInjectorBootstrap.getRabbitmqDirectorySce().getClusterFromNode(this.rabbitmqNode);
        switch (super.getNextAction()) {
            case Component.ACTION_UPDATE:
                break;
            case Component.ACTION_CREATE:
                break;
            case Component.ACTION_DELETE:
                break;
            default:
                log.error("Unknown entity refresh !");
                break;
        }

        super.setLastRefresh(new Date());
        RabbitmqInjectorBootstrap.getComponentsRegistry().putEntityToCache(this);
        super.setRefreshing(false);
    }

    @Override
    public void refreshAndMap() {

    }
}
{'fraction_non_alphanumeric': 0.07873684210526316, 'fraction_numerical': 0.0032280701754385964, 'mean_word_length': 3.4874055415617127, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3529558', 'n_tokens_mistral': 1996, 'n_tokens_neox': 1871, 'n_words': 507}