public static String makeId ( final Item item, final String tag ) { return item.getName () + delimiter + tag; }
public static String makeId ( final Item item, final String tag ) { return item.getName () + delimiter + tag; }
public static Item findMasterItem ( final MasterServer master, final String name ) { // FIXME: speed up for ( final Item item : master.getItems () ) { if ( item.getName ().equals ( name ) ) { return item; } } return null; }
public static Item findMasterItem ( final MasterServer master, final String name ) { // FIXME: speed up for ( final Item item : master.getItems () ) { if ( item.getName ().equals ( name ) ) { return item; } } return null; }
private String makeGlobalSummaryName ( final Global global, final Local local, final Item item ) { return "SYSTEM" + Names.delimiter + "globalizedSummaries" + Names.delimiter + local.getId () + Names.delimiter + item.getName (); }
private String createSource ( final ValueArchive archive, final Item item, final int number ) { final Map<String, String> data = new HashMap<String, String> (); final DataAccessConnection connection = findConnection ( item ); data.put ( "item.id", item.getName () ); //$NON-NLS-1$ data.put ( "connection.id", Names.makeName ( connection ) ); //$NON-NLS-1$ final String id = makeId ( archive, number, "source" ); addData ( Factories.FACTORY_DA_SOURCE, id, data ); return id; }
private String createSource ( final ValueArchive archive, final Item item, final int number ) { final Map<String, String> data = new HashMap<String, String> (); final DataAccessConnection connection = findConnection ( item ); data.put ( "item.id", item.getName () ); //$NON-NLS-1$ data.put ( "connection.id", Names.makeName ( connection ) ); //$NON-NLS-1$ final String id = makeId ( archive, number, "source" ); addData ( Factories.FACTORY_DA_SOURCE, id, data ); return id; }
public static void addArchive ( final ValueArchiveServer archiveServer, final Item item ) { final ValueArchive archive = OsgiFactory.eINSTANCE.createValueArchive (); archiveServer.getArchives ().add ( archive ); archive.setName ( item.getName () ); archive.getItems ().add ( item ); }
public static void addArchive ( final ValueArchiveServer archiveServer, final Item item ) { final ValueArchive archive = OsgiFactory.eINSTANCE.createValueArchive (); archiveServer.getArchives ().add ( archive ); archive.setName ( item.getName () ); archive.getItems ().add ( item ); }
@Override protected void process ( final RestExporter exporter, final EquinoxApplication app, final OscarContext ctx, final IProgressMonitor monitor ) { final Profile profile = Profiles.createOrGetCustomizationProfile ( app ); Profiles.addStartBundle ( profile, "org.eclipse.scada.da.server.exporter.rest" ); final Map<String, String> data = new HashMap<String, String> ( exporter.getItems ().size () + exporter.getHiveProperties ().size () ); data.putAll ( Properties.makeAttributes ( "hive.", exporter.getHiveProperties () ) ); for ( final Item item : exporter.getItems () ) { data.put ( "items." + item.getName (), item.getName () ); } ctx.addData ( Factories.FACTORY_DA_REST_EXPORTER, exporter.getContextId (), data ); }
@Override protected void process ( final RestExporter exporter, final EquinoxApplication app, final OscarContext ctx, final IProgressMonitor monitor ) { final Profile profile = Profiles.createOrGetCustomizationProfile ( app ); Profiles.addStartBundle ( profile, "org.eclipse.scada.da.server.exporter.rest" ); final Map<String, String> data = new HashMap<String, String> ( exporter.getItems ().size () + exporter.getHiveProperties ().size () ); data.putAll ( Properties.makeAttributes ( "hive.", exporter.getHiveProperties () ) ); for ( final Item item : exporter.getItems () ) { data.put ( "items." + item.getName (), item.getName () ); } ctx.addData ( Factories.FACTORY_DA_REST_EXPORTER, exporter.getContextId (), data ); }
public static void addItem ( final MasterServer master, final Item item ) { // adding item master.getItems ().add ( item ); // export item on all DA exporters for ( final Exporter exporter : master.getExporter () ) { if ( exporter instanceof DataAccessExporter ) { final ItemExport itemExport = OsgiFactory.eINSTANCE.createItemExport (); itemExport.setExportName ( item.getName () ); itemExport.setItem ( item ); ( (DataAccessExporter)exporter ).getExports ().add ( itemExport ); } } }
public static void addItem ( final MasterServer master, final Item item ) { // adding item master.getItems ().add ( item ); // export item on all DA exporters for ( final Exporter exporter : master.getExporter () ) { if ( exporter instanceof DataAccessExporter ) { final ItemExport itemExport = OsgiFactory.eINSTANCE.createItemExport (); itemExport.setExportName ( item.getName () ); itemExport.setItem ( item ); ( (DataAccessExporter)exporter ).getExports ().add ( itemExport ); } } }
@Override public void createItems ( final ItemCreator itemCreator ) { for ( final DataComponent component : this.globalize.getComponents () ) { final Map<List<String>, ItemCreation> items = createItems ( component ); for ( final Map.Entry<List<String>, ItemCreation> entry : items.entrySet () ) { final CreationRequest<SourceItem> req = itemCreator.createImportItem ( this.globalize.getSourceMaster (), entry.getValue ().getItem ().getName () ); req.request ( entry.getValue ().getCustomizationRequest () ); req.addCustomizationTags ( "globalized" ); req.incrementGlobalizationLevel (); // override the local tags with the original local tags, not the modified ones req.localTags ( entry.getKey () ); // now create the item req.create (); } } }
protected <T extends Item> T addItem ( final T item, final CustomizationRequest customizationRequest, final Set<MasterListener<T>> masterListeners ) { final List<String> originalLocalTags = new ArrayList<> ( customizationRequest.getLocalTags () ); // we do need a copy customizeItem ( item, customizationRequest ); // set the name after customizing final List<String> hier = new LinkedList<> (); hier.addAll ( customizationRequest.getHierarchy () ); hier.addAll ( customizationRequest.getLocalTags () ); item.setName ( Names.makeHierarchy ( hier ) ); // FIXME: should allow a different naming scheme logger.debug ( "Setting item name: {}", item.getName () ); if ( item.getInformation () == null ) { item.setInformation ( OsgiFactory.eINSTANCE.createItemInformation () ); } // apply the hierarchy afterwards ... overriding! ECollections.setEList ( item.getInformation ().getHierarchy (), customizationRequest.getHierarchy () ); itemAdded ( item, customizationRequest, originalLocalTags, masterListeners ); return item; }
protected <T extends Item> T addItem ( final T item, final CustomizationRequest customizationRequest, final Set<MasterListener<T>> masterListeners ) { final List<String> originalLocalTags = new ArrayList<> ( customizationRequest.getLocalTags () ); // we do need a copy customizeItem ( item, customizationRequest ); // set the name after customizing final List<String> hier = new LinkedList<> (); hier.addAll ( customizationRequest.getHierarchy () ); hier.addAll ( customizationRequest.getLocalTags () ); item.setName ( Names.makeHierarchy ( hier ) ); // FIXME: should allow a different naming scheme logger.debug ( "Setting item name: {}", item.getName () ); if ( item.getInformation () == null ) { item.setInformation ( OsgiFactory.eINSTANCE.createItemInformation () ); } // apply the hierarchy afterwards ... overriding! ECollections.setEList ( item.getInformation ().getHierarchy (), customizationRequest.getHierarchy () ); itemAdded ( item, customizationRequest, originalLocalTags, masterListeners ); return item; }
public static Map<String, String> createInfoAttributes ( final Item item ) { final Map<String, String> attributes = new HashMap<> (); Configurations.fillAttributesWithHierarchy ( attributes, Names.makeHierarchy ( item ) ); attributes.put ( "item", item.getName () ); if ( item.getInformation () != null ) { addAttribute ( attributes, "system", item.getInformation ().getSystem () ); addAttribute ( attributes, "unit", item.getInformation ().getUnit () ); addAttribute ( attributes, "itemDescription", item.getInformation ().getDescription () ); } return attributes; }
public static Map<String, String> createInfoAttributes ( final Item item ) { final Map<String, String> attributes = new HashMap<> (); Configurations.fillAttributesWithHierarchy ( attributes, Names.makeHierarchy ( item ) ); attributes.put ( "item", item.getName () ); if ( item.getInformation () != null ) { addAttribute ( attributes, "system", item.getInformation ().getSystem () ); addAttribute ( attributes, "unit", item.getInformation ().getUnit () ); addAttribute ( attributes, "itemDescription", item.getInformation ().getDescription () ); } return attributes; }
private SourceItem createGlobalItem ( final Global global, final Local local, final Item item, final DataAccessConnection da ) { final SourceItem sourceItem = OsgiFactory.eINSTANCE.createSourceItem (); sourceItem.setInformation ( EcoreUtil.copy ( item.getInformation () ) ); sourceItem.setSourceName ( item.getName () ); sourceItem.setConnection ( da ); if ( item instanceof SummaryItem ) { sourceItem.setName ( makeGlobalSummaryName ( global, local, item ) ); } else { sourceItem.setName ( item.getName () ); } // FIXME: customize global item final int level = findAttributesHierarchyLevel ( item ) + 1; DefaultFeatures.ASUM ( level ).customize ( sourceItem ); this.hierarchyLevelMap.put ( sourceItem, level ); return sourceItem; }
protected void processItems ( final Global global, final Local local, final DataAccessConnection da ) { final List<DataAccessExporter> exporters = new TypeWalker<> ( DataAccessExporter.class ).toList ( global.getGlobal () ); int count = 0; for ( final Item item : local.getLocal ().getItems () ) { if ( !isIncluded ( local, item ) ) { continue; } final SourceItem sourceItem = createGlobalItem ( global, local, item, da ); global.getGlobal ().getItems ().add ( sourceItem ); final ItemExport export = OsgiFactory.eINSTANCE.createItemExport (); export.setExportName ( item.getName () ); export.setItem ( sourceItem ); // add the export for ( final DataAccessExporter exp : exporters ) { exp.getExports ().add ( export ); } count++; } logger.info ( "Globalized {} items", count ); }